//package com.qujia.station.service.impl;
//
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//import java.sql.Time;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//import java.time.ZoneId;
//import java.util.*;
//
//import com.qujia.common.core.domain.AjaxResult;
//import com.qujia.common.core.domain.entity.SysUser;
//import com.qujia.common.core.domain.model.LoginUser;
//import com.qujia.common.utils.DateUtils;
//import com.qujia.common.utils.MathUtil;
//import com.qujia.common.utils.SecurityUtils;
//import com.qujia.common.utils.StringUtils;
//import com.qujia.customer.enums.CardRecordType;
//import com.qujia.station.domain.*;
//import com.qujia.station.domain.dto.CardClassSettDto;
//import com.qujia.station.domain.dto.OilEngineDto;
//import com.qujia.station.domain.dto.OilEngineSumDto;
//import com.qujia.station.domain.dto.StationClassTimeDto;
//import com.qujia.station.domain.vo.StationClassTimeVo;
//import com.qujia.station.domain.vo.changeClassSettlement4User;
//import com.qujia.station.mapper.*;
//import com.qujia.station.service.ClassSettlementCardService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.stereotype.Service;
//import com.qujia.station.service.IClassSettlementService;
//
//import javax.annotation.Resource;
//
///**
// * 班结Service业务层处理
// *
// * @author qujia
// * @date 2021-11-27
// */
//@Service
//public class ClassSettlementServiceImpl implements IClassSettlementService {
//    @Autowired
//    private ClassSettlementMapper classSettlementMapper;
//    @Resource
//    private OilOmeterMapper oilOmeterMapper;
//
//    @Autowired
//    private ClassSettlementCardMapper classSettlementCardMapper;
//    @Autowired
//    private ClassSettlementCardService classSettlementCardService;
//    @Autowired
//    private StationMapper stationMapper;
//    @Autowired
//    private EnterpriseMapper enterpriseMapper;
//
//    /**
//     * 查询班结
//     *
//     * @param classSettlementId 班结ID
//     * @return 班结
//     */
//    @Override
//    public ClassSettlement selectClassSettlementById(Long classSettlementId) {
//        return classSettlementMapper.selectClassSettlementById(classSettlementId);
//    }
//
//    /**
//     * 查询班结列表
//     *
//     * @param classSettlement 班结
//     * @return 班结
//     */
//    @Override
//    public List<ClassSettlement> selectClassSettlementList(ClassSettlement classSettlement) {
//        return classSettlementMapper.selectClassSettlementList(classSettlement);
//    }
//
//    /**
//     * 查询班结汇总列表
//     *
//     * @param classSettlement 班结
//     * @return 班结
//     */
//    @Override
//    public List<ClassSettlement> selectClassSettlementSummaryList(ClassSettlement classSettlement) {
//        return classSettlementMapper.selectClassSettlementSummaryList(classSettlement);
//    }
//
//    @Override
//    public List<BusinessDailyReport> selectBusinessDailyReportList(ClassSettlement classSettlement) {
//        return classSettlementMapper.selectBusinessDailyReportList(classSettlement);
//    }
//
//    @Override
//    public BusinessDailyReport selectBusinessDailyReportSum(ClassSettlement classSettlement) {
//        return classSettlementMapper.selectBusinessDailyReportSum(classSettlement);
//    }
//
//    @Override
//    public List<ReportSettlement> selectReportClassList(ClassSettlement classSettlement) {
//        LoginUser current = SecurityUtils.getLoginUser();
//        if ("1".equals(current.getUser().getUserLevel())) {
//            Station station = new Station();
//            station.setEnterpriseId(current.getUser().getEnterpriseId());
//            List<String> list = new ArrayList<>();
//            List<Station> stations = stationMapper.selectStationList(station);
//            for (Station ss : stations) {
//                list.add(ss.getStationId() + "");
//            }
//            if (stations != null && stations.size() > 0) {
//                classSettlement.setStationIdList(list);
//            }
//
//        } else if ("2".equals(current.getUser().getUserLevel())) {
//            classSettlement.setStationId(current.getUser().getStationId());
//        } else {
//
//        }
//        List<ReportSettlement> reportClass = classSettlementMapper.selectReportClassList(classSettlement);
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        for(ReportSettlement reportSettlement:reportClass){
//            if (reportSettlement.getClassStartTime() != null) {
//
//                Date startTime = reportSettlement.getClassStartTime();
//                String formattedStartTime = sdf.format(startTime);
//                classSettlement.setBeginTime(formattedStartTime);
//            } else {
//                classSettlement.setBeginTime(null);
//            }
//
//            if (reportSettlement.getClassEndTime() != null) {
//                Date endTime = reportSettlement.getClassEndTime();
//                String formattedEndTime = sdf.format(endTime);
//                classSettlement.setEndTime(formattedEndTime);
//                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//                String formattedDate = dateFormat.format(endTime);
//                reportSettlement.setTimeOnTrade(formattedDate);
//            } else {
//                classSettlement.setEndTime(null);
//            }
//            classSettlement.setStationId(reportSettlement.getStationId());
//            classSettlement.setTimeOnTrade(reportSettlement.getTimeOnTrade());
//            BigDecimal a =   classSettlementMapper.totalWordCount(classSettlement);
//            if(a != null){
//                reportSettlement.setTotalWordCount(a);
//            }
//        }
//        return reportClass;
//    }
//
//    @Override
//    public List<ClassSettlementCard> getTransactionSummary(CardClassSettDto settDto, Map<String, Object> params) {
//        List<ClassSettlementCard> transactionSummary = new ArrayList<>();
//        List<ClassSettlementCard> settCardList = settDto.getSettlementCardList();
//        ClassSettlementCard wxrefClassSettlementCard = new ClassSettlementCard();
//        ClassSettlementCard posrefClassSettlementCard = new ClassSettlementCard();
//        for (ClassSettlementCard settCard : settCardList) {
//            if (settCard.getPayType() != null && settCard.getPayType().equals(CardRecordType.WX_REFUND.getKey())) {
//                wxrefClassSettlementCard = settCard;
//            }
//            if (settCard.getPayType() != null && settCard.getPayType().equals(CardRecordType.POS_REFUND.getKey())) {
//                posrefClassSettlementCard = settCard;
//            }
//        }
//        for (ClassSettlementCard settCard : settCardList) {
//            if (settCard.getPayType() != null && settCard.getPayType().equals("imp")) {
//                transactionSummary.add(settCard);
//            }else if(settCard.getPayType() != null && settCard.getPayType().equals("pos")) {
//                settCard.setAmt(settCard.getAmt().subtract(posrefClassSettlementCard.getAmt()== null ? BigDecimal.ZERO : posrefClassSettlementCard.getAmt()));
//                settCard.setGiveAmt(settCard.getGiveAmt().subtract(posrefClassSettlementCard.getGiveAmt()== null ? BigDecimal.ZERO : posrefClassSettlementCard.getGiveAmt()));
//                if (settCard.getOrderCount() != null && posrefClassSettlementCard.getOrderCount() != null) {
//                    settCard.setOrderCount(settCard.getOrderCount() - posrefClassSettlementCard.getOrderCount());
//                }
//                transactionSummary.add(settCard);
//            }
//            else if (settCard.getPayType() != null && settCard.getPayType().equals("wx")) {
//                settCard.setAmt(settCard.getAmt().subtract(wxrefClassSettlementCard.getAmt()== null ? BigDecimal.ZERO : wxrefClassSettlementCard.getAmt()));
//                settCard.setGiveAmt(settCard.getGiveAmt().subtract(wxrefClassSettlementCard.getGiveAmt()== null ? BigDecimal.ZERO : wxrefClassSettlementCard.getGiveAmt()));
//                if (settCard.getOrderCount() != null && wxrefClassSettlementCard.getOrderCount() != null) {
//                    settCard.setOrderCount(settCard.getOrderCount() - wxrefClassSettlementCard.getOrderCount());
//                }
//                transactionSummary.add(settCard);
//            }
//        }
//        ClassSettlementCard physicalCardInXj = classSettlementMapper.queryPhysicalCardInXj(params);
//        physicalCardInXj.setPayType("dkqxj");
//        ClassSettlementCard physicalCardInWxPos = classSettlementMapper.queryPhysicalCardInWxPos(params);
//        physicalCardInWxPos.setPayType("dkqwxpos");
//        ClassSettlementCard physicalCardInRef = classSettlementMapper.queryPhysicalCardInRef(params);
//        physicalCardInRef.setPayType("dkqref");
//        if (physicalCardInWxPos.getAmt()!=null && physicalCardInRef.getAmt()!=null){
//            BigDecimal wxpos =   physicalCardInWxPos.getAmt().subtract(physicalCardInRef.getAmt());
//            BigDecimal wxposgift =   BigDecimal.ZERO;
//            long wxposcount =   physicalCardInWxPos.getOrderCount()-physicalCardInRef.getOrderCount();
//            physicalCardInWxPos.setAmt(wxpos);
//            physicalCardInWxPos.setGiveAmt(wxposgift);
//            physicalCardInWxPos.setOrderCount(wxposcount);
//        }
//        ClassSettlementCard physicalCard = classSettlementMapper.queryPhysicalCard(params);
//        physicalCard.setPayType("dkq");
//        ClassSettlementCard fleetCard = classSettlementMapper.queryFleetCard(params);
//        fleetCard.setPayType("cdk");
//        ClassSettlementCard SuperPay = classSettlementMapper.querySuperPay(params);
//        SuperPay.setPayType("cjhyxs");
//        ClassSettlementCard cxhysd =new ClassSettlementCard();
//        cxhysd.setPayType("cjhysd");
//        transactionSummary.add(physicalCardInXj);
//        transactionSummary.add(physicalCardInWxPos);
//        transactionSummary.add(fleetCard);
//        transactionSummary.add(SuperPay);
//        transactionSummary.add(cxhysd);
//        ClassSettlementCard alltransaction = new ClassSettlementCard();
//        alltransaction.setPayType("合计");
//        BigDecimal totalAmt = BigDecimal.ZERO;
//        BigDecimal totalWithdrawalAmount = BigDecimal.ZERO;
//        BigDecimal giveAmt = BigDecimal.ZERO;
//
//        Long totalOrderCount = 0L;
//
//        for (ClassSettlementCard transaction : transactionSummary) {
//            if (transaction.getAmt() != null) {
//                totalAmt = totalAmt.add(transaction.getAmt());
//            }
//            if (transaction.getWithdrawalAmount() != null) {
//                totalWithdrawalAmount = totalWithdrawalAmount.add(transaction.getWithdrawalAmount());
//            }
//            if (transaction.getGiveAmt() != null) {
//                giveAmt = giveAmt.add(transaction.getGiveAmt());
//            }
//            if (transaction.getOrderCount() != null) {
//                totalOrderCount = totalOrderCount + transaction.getOrderCount();
//            }
//        }
//
//        alltransaction.setAmt(totalAmt);
//        alltransaction.setGiveAmt(giveAmt);
//        alltransaction.setWithdrawalAmount(totalWithdrawalAmount);
//        alltransaction.setOrderCount(totalOrderCount);
//        transactionSummary.add(alltransaction);
//        return transactionSummary;
//    }
//
//    @Override
//    public List<ClassSettlement> getRefundSummary(CardClassSettDto settDto, Map<String, Object> params) {
//        List<ClassSettlement> refundSummary = new ArrayList<>();
//        List<ClassSettlementCard> settCardList = settDto.getSettlementCardList();
//        ClassSettlement refSettlement = new ClassSettlement();
//        for (ClassSettlementCard settCard : settCardList) {
//            if (settCard.getPayType() != null && settCard.getPayType().equals("ref")) {
//                if (settCard.getOrderCount() != null && settCard.getOrderCount() != 0L) {
//                    refSettlement.setPayType("ref");
//                    refSettlement.setRefundAmt(settCard.getAmt());
//                    refSettlement.setOrderCount(settCard.getOrderCount());
//                    refundSummary.add(refSettlement);
//                }
//            }
//        }
//        ClassSettlementCard refSaleActivity= classSettlementMapper.refSaleActivityAmt(params);
//        ClassSettlement msSettlement = new ClassSettlement();
//        msSettlement.setPayType("msref");
//        msSettlement.setRefundAmt(refSaleActivity.getAmt()!=null?refSaleActivity.getAmt():BigDecimal.ZERO);
//        msSettlement.setOrderCount(refSaleActivity.getOrderCount());
//        refundSummary.add(msSettlement);
//        // 根据油品分组查询统计信息
//        List<Map<String, Object>> queryGroupByPayType = classSettlementMapper.queryGroupRefundByPayTypeForOrder(params);
//        Iterator<Map<String, Object>> iterator3 = queryGroupByPayType.iterator();
//        ClassSettlementCard refundSuperPay = classSettlementMapper.queryRefundSuperPay(params);
//        ClassSettlementCard physicalCardInRef = classSettlementMapper.queryPhysicalCardInRef(params);
//
//        double refundSuperPayAmt = refundSuperPay.getAmt()!=null ?refundSuperPay.getAmt().doubleValue():0.0;
//        BigDecimal refundSuperPayCount = refundSuperPay.getOrderCount()!=null ?new BigDecimal(refundSuperPay.getOrderCount()):BigDecimal.ZERO;
//        double physicalCardInRefAmt = physicalCardInRef.getAmt()!=null ?physicalCardInRef.getAmt().doubleValue():0.0;
//        BigDecimal physicalCardInRefCount = physicalCardInRef.getOrderCount()!=null ?new BigDecimal(physicalCardInRef.getOrderCount()):BigDecimal.ZERO;
//
//        while (iterator3.hasNext()) {
//            Map<String, Object> map = iterator3.next();
//            if (!map.containsKey("pay_type")) {
//                iterator3.remove();
//            }
//        }
//        Map<String, Object> itemPayTypeMap = new HashMap<>();
//        itemPayTypeMap.put("pay_type","sref");
//        itemPayTypeMap.put("refund_amt",refundSuperPayAmt);
//        itemPayTypeMap.put("order_count",refundSuperPayCount);
//        queryGroupByPayType.add(itemPayTypeMap);
//        Map<String, Object> itemPayTypeSTKMap = new HashMap<>();
//        itemPayTypeSTKMap.put("pay_type","dkqwxposref");
//        itemPayTypeSTKMap.put("refund_amt",physicalCardInRefAmt);
//        itemPayTypeSTKMap.put("order_count",physicalCardInRefCount);
//        queryGroupByPayType.add(itemPayTypeSTKMap);
//        for (Map<String, Object> itemPayType : queryGroupByPayType) {
//            ClassSettlement refunditem = new ClassSettlement();
//            refunditem.setPayType(itemPayType.get("pay_type").toString());
//            Object refundAmtObj = itemPayType.get("refund_amt");
//            double refundAmtDouble = (refundAmtObj != null) ? (double) refundAmtObj : 0.0;
//            BigDecimal refundAmt = BigDecimal.valueOf(refundAmtDouble);
//            if (refundAmt != null) {
//                refunditem.setRefundAmt(refundAmt);
//            }
//            Object countObj = itemPayType.get("order_count");
//            Long count = (countObj != null) ? ((BigDecimal) countObj).longValue() : 0L;
//            if (count != null) {
//                refunditem.setOrderCount(count);
//            }
//            refundSummary.add(refunditem);
//        }
//        ClassSettlement allRefund = new ClassSettlement();
//        allRefund.setPayType("合计");
//        BigDecimal allRefundAmt = BigDecimal.ZERO;
//        Long totalOrderCount = 0L;
//        for (ClassSettlement refunditem : refundSummary) {
//            if (refunditem.getRefundAmt() != null) {
//                allRefundAmt = allRefundAmt.add(refunditem.getRefundAmt());
//            }
//
//            if (refunditem.getOrderCount() != null) {
//                totalOrderCount = totalOrderCount + refunditem.getOrderCount();
//            }
//        }
//        allRefund.setRefundAmt(allRefundAmt);
//        allRefund.setOrderCount(totalOrderCount);
//        refundSummary.add(allRefund);
//        return refundSummary;
//    }
//
//    @Override
//    public List<ClassSettlement> employeeGetRefundSummary(Map<String, Object> params) {
//        List<ClassSettlement> refundSummary = new ArrayList<>();
//
//        // 员工权限下不统计电子卡（会员卡）充值退款
////        List<ClassSettlementCard> settCardList = settDto.getSettlementCardList();
////        ClassSettlement refSettlement = new ClassSettlement();
////        for (ClassSettlementCard settCard : settCardList) {
////            if (settCard.getPayType() != null && settCard.getPayType().equals("ref")) {
////                if (settCard.getOrderCount() != null && settCard.getOrderCount() != 0L) {
////                    refSettlement.setPayType("ref");
////                    refSettlement.setRefundAmt(settCard.getAmt());
////                    refSettlement.setOrderCount(settCard.getOrderCount());
////                    refundSummary.add(refSettlement);
////                }
////            }
////        }
//
//        // 根据员工+支付方式分组查询统计信息
//        List<Map<String, Object>> queryGroupByPayType = classSettlementMapper.employeeQueryGroupRefundByPayTypeForOrder(params);
//        Iterator<Map<String, Object>> iterator3 = queryGroupByPayType.iterator();
//        while (iterator3.hasNext()) {
//            Map<String, Object> map = iterator3.next();
//            if (!map.containsKey("pay_type")) {
//                iterator3.remove();
//            }
//        }
//        for (Map<String, Object> itemPayType : queryGroupByPayType) {
//            ClassSettlement refunditem = new ClassSettlement();
//            refunditem.setPayType(itemPayType.get("pay_type").toString());
//            Object refundAmtObj = itemPayType.get("refund_amt");
//            double refundAmtDouble = (refundAmtObj != null) ? (double) refundAmtObj : 0.0;
//            BigDecimal refundAmt = BigDecimal.valueOf(refundAmtDouble);
//            if (refundAmt != null) {
//                refunditem.setRefundAmt(refundAmt);
//            }
//            Object countObj = itemPayType.get("order_count");
//            Long count = (countObj != null) ? ((BigDecimal) countObj).longValue() : 0L;
//            if (count != null) {
//                refunditem.setOrderCount(count);
//            }
//            refundSummary.add(refunditem);
//        }
//        ClassSettlement allRefund = new ClassSettlement();
//        allRefund.setPayType("合计");
//        BigDecimal allRefundAmt = BigDecimal.ZERO;
//        Long totalOrderCount = 0L;
//        for (ClassSettlement refunditem : refundSummary) {
//            if (refunditem.getRefundAmt() != null) {
//                allRefundAmt = allRefundAmt.add(refunditem.getRefundAmt());
//            }
//
//            if (refunditem.getOrderCount() != null) {
//                totalOrderCount = totalOrderCount + refunditem.getOrderCount();
//            }
//        }
//        allRefund.setRefundAmt(allRefundAmt);
//        allRefund.setOrderCount(totalOrderCount);
//        refundSummary.add(allRefund);
//        return refundSummary;
//    }
//
//    @Override
//    public ClassSettlement selectClassSettlementSummary(ClassSettlement classSettlement) {
//        return classSettlementMapper.selectClassSettlementSummary(classSettlement);
//    }
//
//    @Override
//    public ReportSettlement selectClassReportmentSummary(ClassSettlement classSettlement) {
//        ReportSettlement reportSettlement = classSettlementMapper.selectClassReportmentSummary(classSettlement);
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        if (reportSettlement.getClassStartTime() != null) {
//
//            Date startTime = reportSettlement.getClassStartTime();
//            String formattedStartTime = sdf.format(startTime);
//            classSettlement.setBeginTime(formattedStartTime);
//        } else {
//            classSettlement.setBeginTime(null);
//        }
//
//        if (reportSettlement.getClassEndTime() != null) {
//            Date endTime = reportSettlement.getClassEndTime();
//            String formattedEndTime = sdf.format(endTime);
//            classSettlement.setEndTime(formattedEndTime);
//            reportSettlement.setTimeOnTrade(formattedEndTime);
//        } else {
//            classSettlement.setEndTime(null);
//        }
//      BigDecimal a =   classSettlementMapper.totalWordCount(classSettlement);
//      if(a != null){
//          reportSettlement.setTotalWordCount(a);
//      }
//        return reportSettlement;
//    }
//
//    @Override
//    public List<ClassSettlementOilmachine> selectAllClassSettlementOilmachines(String classNo) {
//
//        return classSettlementMapper.selectAllClassSettlementOilmachines(classNo);
//    }
//
//
//    @Override
//    public BigDecimal totalWordCount(ClassSettlement classSettlement) {
//
//        return classSettlementMapper.totalWordCount(classSettlement);
//    }
//
//    @Override
//    public List<ClassSettlement> selectClassSettlementSummary4POSList(Map<String, Object> params) {
//        return classSettlementMapper.selectClassSettlementSummary4POSList(params);
//    }
//
//    @Override
//    public AjaxResult getInfoForOrder(String createStartTime,
//                                      String createEndTime,
//                                      Long stationId,
//                                      CardClassSettDto settDto) {
//
//        if (stationId == null || stationId.equals("")) {
//            return AjaxResult.error("没有油站");
//        }
//        Map<String, Object> resultMap = new HashMap<String, Object>();
//        Map<String, Object> queryMap = new HashMap<String, Object>();
//        queryMap.put("createStartTime", createStartTime);
//        queryMap.put("createEndTime", createEndTime);
//        queryMap.put("stationId", stationId);
//        List<ClassSettlement> querySummaryByClassNo = this.querySummaryByClassNoForOrder(queryMap);
//// 根据班结编号查询班结摘要信息
//        List<Map<String, Object>> queryGroupByOil = this.queryGroupByOilForOrder(queryMap);
//        Iterator<Map<String, Object>> iterator = queryGroupByOil.iterator();
//        while (iterator.hasNext()) {
//            Map<String, Object> map = iterator.next();
//            if (!map.containsKey("oil_name")) {
//                iterator.remove();
//            }
//        }
//        Map<String, Object> allOil = new HashMap<String, Object>();
//        BigDecimal orderLiterSum = BigDecimal.ZERO;
//        BigDecimal receivableAmtSum = BigDecimal.ZERO;
//        BigDecimal amtSum = BigDecimal.ZERO;
//        BigDecimal discountAmtSum = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSum = BigDecimal.ZERO;
//        BigDecimal orderCountSum = BigDecimal.ZERO;
//        for (Map<String, Object> itemOil : queryGroupByOil) {
//            Object orderLiterObj = itemOil.get("order_liters");
//            double orderLiterDouble = (orderLiterObj != null) ? (double) orderLiterObj : 0.0;
//            BigDecimal orderLiter = BigDecimal.valueOf(orderLiterDouble);
//            if (orderLiter != null) {
//                orderLiterSum = orderLiterSum.add(orderLiter);
//            }
//
//            Object receivableAmtObj = itemOil.get("receivable_amt");
//            double receivableAmtDouble = (receivableAmtObj != null) ? (double) receivableAmtObj : 0.0;
//            BigDecimal receivableAmt = BigDecimal.valueOf(receivableAmtDouble);
//            if (receivableAmt != null) {
//                receivableAmtSum = receivableAmtSum.add(receivableAmt);
//            }
//
//            Object amtObj = itemOil.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSum = amtSum.add(amt);
//            }
//
//            Object discountAmtObj = itemOil.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSum = discountAmtSum.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemOil.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSum = discountCouponAmtSum.add(discountCouponAmt);
//            }
//            Object orderCountObj = itemOil.get("order_count");
//            BigDecimal orderCount = (orderCountObj != null) ? (BigDecimal) orderCountObj : BigDecimal.ZERO;
//            BigDecimal orderCountBigDecimal = orderCount;
//            if (orderCountBigDecimal != null) {
//                orderCountSum = orderCountSum.add(orderCountBigDecimal);
//            }
//        }
//        allOil.put("oil_name", "合计");
//        allOil.put("order_liters", orderLiterSum);
//        allOil.put("receivable_amt", receivableAmtSum);
//        allOil.put("amt", amtSum);
//        allOil.put("discount_amt", discountAmtSum);
//        allOil.put("discount_coupon_amt", discountCouponAmtSum);
//        allOil.put("order_count", orderCountSum);
//        queryGroupByOil.add(allOil);
//
//// 根据油品分组查询统计信息
//        List<Map<String, Object>> queryGroupByPayType = this.queryGroupByPayTypeForOrder(queryMap);
//        Iterator<Map<String, Object>> iterator3 = queryGroupByPayType.iterator();
//        while (iterator3.hasNext()) {
//            Map<String, Object> map = iterator3.next();
//            if (!map.containsKey("pay_type")) {
//                iterator3.remove();
//            }
//        }
//        Map<String, Object> allPayType = new HashMap<>();
//        BigDecimal amtSum2 = BigDecimal.ZERO;
//        BigDecimal refundAmtSum2 = BigDecimal.ZERO;
//        BigDecimal discountAmtSum2 = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSum2 = BigDecimal.ZERO;
//
//        for (Map<String, Object> itemPayType : queryGroupByPayType) {
//            Object amtObj = itemPayType.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSum2 = amtSum2.add(amt);
//            }
//
//            Object refundAmtObj = itemPayType.get("refund_amt");
//            double refundAmtDouble = (refundAmtObj != null) ? (double) refundAmtObj : 0.0;
//            BigDecimal refundAmt = BigDecimal.valueOf(refundAmtDouble);
//            if (refundAmt != null) {
//                refundAmtSum2 = refundAmtSum2.add(refundAmt);
//            }
//
//            Object discountAmtObj = itemPayType.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSum2 = discountAmtSum2.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemPayType.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSum2 = discountCouponAmtSum2.add(discountCouponAmt);
//            }
//        }
//        for(Map<String, Object> item :queryGroupByPayType){
//            Map<String, Object> OrderPayqueryMap = new HashMap<String, Object>();
//            OrderPayqueryMap.put("payType", item.get("pay_type"));
//            OrderPayqueryMap.put("stationId", item.get("station_id"));
//            String orderPayType = classSettlementMapper.queryOrderPayType(OrderPayqueryMap);
//            if(orderPayType!=null){
//                item.put("pay_type",orderPayType);
//            }
//        }
//        allPayType.put("pay_type", "合计");
//        allPayType.put("amt", amtSum2);
//        allPayType.put("refund_amt", refundAmtSum2);
//        allPayType.put("discount_amt", discountAmtSum2);
//        allPayType.put("discount_coupon_amt", discountCouponAmtSum2);
//
//        queryGroupByPayType.add(allPayType);
//
//// 根据支付方式分组查询统计信息
//        List<Map<String, Object>> queryGroupByOilGun = this.queryGroupByOilGunForOrder(queryMap);
//        Iterator<Map<String, Object>> iterator2 = queryGroupByOilGun.iterator();
//        while (iterator2.hasNext()) {
//            Map<String, Object> map = iterator2.next();
//            if (!map.containsKey("oil_gun")) {
//                iterator2.remove();
//            }
//        }
//        List<OilEngineDto> newQueryGroupByOilGun = classSettlementMapper.classSettlementOilEngineSum(queryMap);
//        List<String> oilGunListA = new ArrayList<>();
//        List<String> oilGunListB = new ArrayList<>();
//        if (queryGroupByOilGun.size() > 0 && newQueryGroupByOilGun.size() > 0) {
//            for (Map<String, Object> map : queryGroupByOilGun) {
//                String oilGun = map.get("oil_gun").toString();
//                oilGunListA.add(oilGun); // 存储a列表的油枪数据
//                oilGunListB.clear();
//                for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                    oilGunListB.add(oilEngineDto.getOilGun());
//                    if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//                        map.put("oil_price", oilEngineDto.getOilPrice());
//                        map.put("order_liters", oilEngineDto.getOrderLiters());
//                        map.put("oil_name", oilEngineDto.getOilName());
//                        map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                        map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                    }
//                }
//            }
//            List<String> difference = new ArrayList<>();
//            for (String value : oilGunListB) {
//                if (!oilGunListA.contains(value)) {
//                    difference.add(value);
//                }
//            }
//            for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                for (String oilGun : difference) {
//
//                    if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//
//                        Map<String, Object> map = new HashMap<>();
//                        map.put("oil_gun", oilEngineDto.getOilGun());
//                        map.put("oil_price", oilEngineDto.getOilPrice());
//                        map.put("order_liters", oilEngineDto.getOrderLiters());
//                        map.put("oil_name", oilEngineDto.getOilName());
//                        map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                        map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                        queryGroupByOilGun.add(map);
//                    }
//                }
//            }
//
//        } else if (queryGroupByOilGun.size() == 0 && newQueryGroupByOilGun.size() > 0) {
//            for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                if (oilEngineDto != null && oilEngineDto.getOilGun() != null) {
//                    Map<String, Object> map = new HashMap<>();
//                    map.put("oil_gun", oilEngineDto.getOilGun());
//                    map.put("oil_price", oilEngineDto.getOilPrice());
//                    map.put("order_liters", oilEngineDto.getOrderLiters());
//                    map.put("oil_name", oilEngineDto.getOilName());
//                    map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                    map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                    queryGroupByOilGun.add(map);
//
//                }
//            }
//        }
//
//// 根据油枪号分组查询统计信息
//        List<Map<String, Object>> queryGroupByActivity = this.queryGroupByActivityForOrder(queryMap);
//// 根据活动分组查询统计信息
//        List<Map<String, Object>> listDetail4User = this.selectClassSettlement4User4POSListForOrder(queryMap);
//        Iterator<Map<String, Object>> iterator4 = listDetail4User.iterator();
//        while (iterator4.hasNext()) {
//            Map<String, Object> map = iterator4.next();
//            if (!map.containsKey("oil_name")) {
//                iterator4.remove();
//            }
//        }
//        Map<String, Object> allDetail4User = new HashMap<String, Object>();
//        BigDecimal orderLiterSumForUser = BigDecimal.ZERO;
//        BigDecimal receivableAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal amtSumForUser = BigDecimal.ZERO;
//        BigDecimal discountAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal refundAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal orderCountSumForUser = BigDecimal.ZERO;
//        BigDecimal moreAmtSumForUser = BigDecimal.ZERO;
//
//        for (Map<String, Object> itemOil : listDetail4User) {
//            Object orderLiterObj = itemOil.get("order_liters");
//            double orderLiterDouble = (orderLiterObj != null) ? (double) orderLiterObj : 0.0;
//            BigDecimal orderLiter = BigDecimal.valueOf(orderLiterDouble);
//            if (orderLiter != null) {
//                orderLiterSumForUser = orderLiterSumForUser.add(orderLiter);
//            }
//
//            Object receivableAmtObj = itemOil.get("receivable_amt");
//            double receivableAmtDouble = (receivableAmtObj != null) ? (double) receivableAmtObj : 0.0;
//            BigDecimal receivableAmt = BigDecimal.valueOf(receivableAmtDouble);
//            if (receivableAmt != null) {
//                receivableAmtSumForUser = receivableAmtSumForUser.add(receivableAmt);
//            }
//
//            Object amtObj = itemOil.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSumForUser = amtSumForUser.add(amt);
//            }
//
//            Object discountAmtObj = itemOil.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSumForUser = discountAmtSumForUser.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemOil.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSumForUser = discountCouponAmtSumForUser.add(discountCouponAmt);
//            }
//
//            Object refundAmtObj = itemOil.get("refund_amt");
//            double refundAmtDouble = (refundAmtObj != null) ? (double) refundAmtObj : 0.0;
//            BigDecimal refundAmt = BigDecimal.valueOf(refundAmtDouble);
//            if (refundAmt != null) {
//                refundAmtSumForUser = refundAmtSumForUser.add(refundAmt);
//            }
//
//            Object orderCountObj = itemOil.get("order_count");
//            BigDecimal orderCount = (orderCountObj != null) ? (BigDecimal) orderCountObj : BigDecimal.ZERO;
//            BigDecimal orderCountBigDecimal = orderCount;
//            if (orderCountBigDecimal != null) {
//                orderCountSumForUser = orderCountSumForUser.add(orderCountBigDecimal);
//            }
//
//            Object moreAmtObj = itemOil.get("more_amt");
//            double moreAmtDouble = (moreAmtObj != null) ? (double) moreAmtObj : 0.0;
//            BigDecimal moreAmt = BigDecimal.valueOf(moreAmtDouble);
//            if (moreAmt != null) {
//                moreAmtSumForUser = moreAmtSumForUser.add(moreAmt);
//            }
//        }
//
//        allDetail4User.put("oil_personnel_name", "合计");
//        allDetail4User.put("order_liters", orderLiterSumForUser);
//        allDetail4User.put("receivable_amt", receivableAmtSumForUser);
//        allDetail4User.put("amt", amtSumForUser);
//        allDetail4User.put("discount_amt", discountAmtSumForUser);
//        allDetail4User.put("discount_coupon_amt", discountCouponAmtSumForUser);
//        allDetail4User.put("refund_amt", refundAmtSumForUser);
//        allDetail4User.put("order_count", orderCountSumForUser);
//        allDetail4User.put("more_amt", moreAmtSumForUser);
//
//        listDetail4User.add(allDetail4User);
//// 根据查询条件查询用户的班结详细信息列表
//        ClassSettlementCard classSettlementCard = new ClassSettlementCard();
//        // 确保 createStartTime 不为 null
//        if (createStartTime != null) {
//            // 保留年月日时分秒部分，截取前19个字符
//            String formattedStartTime = createStartTime.substring(0, 19);
//            classSettlementCard.setCreateStartTime(formattedStartTime);
//
//        }
//// 确保 createEndTime 不为 null
//        if (createEndTime != null) {
//            // 保留年月日时分秒部分，截取前19个字符
//            String formattedEndTime = createEndTime.substring(0, 19);
//            classSettlementCard.setCreateEndTime(formattedEndTime);
//
//        }
//        classSettlementCard.setStationId(stationId);
//        List<changeClassSettlement4User> changeClassSettlement4User = classSettlementMapper.selectChange4User4POSListForOrder(queryMap);
//        changeClassSettlement4User allChangeForUser = new changeClassSettlement4User();
//        allChangeForUser.setOilPersonnelName("合计");
//        allChangeForUser.setOrderCount(0);
//        allChangeForUser.setAmt(BigDecimal.ZERO);
//        for(changeClassSettlement4User change4User:changeClassSettlement4User){
//            allChangeForUser.setOrderCount(allChangeForUser.getOrderCount()+change4User.getOrderCount());
//            allChangeForUser.setAmt(allChangeForUser.getAmt().add(change4User.getAmt()));
//        }
//        changeClassSettlement4User.add(allChangeForUser);
//
//        List<ClassSettlementCard> classSettlementCards = classSettlementCardService.queryGroupByPayTypeForOrder(classSettlementCard);
//// 根据支付方式分组查询结算卡信息列表
//        List<ClassSettlementCard> classSettlementCardsGroupByCardType = classSettlementCardService.queryGroupByCardTypeForOrder(classSettlementCard);
//// 根据卡类型分组查询结算卡信息列表
//        List<ClassSettlementCard> classSettlementCardRechargeCardType = classSettlementCardService.queryGroupByRechargeCardTypeForOrder(classSettlementCard);
//        // 根据充值卡类型分组查询结算卡信息列表
//        ClassSettlementCard cardSum = new ClassSettlementCard();
//        cardSum.setAmt(BigDecimal.ZERO);
//        cardSum.setOrderCount(0L);
//        cardSum.setServiceCharge(BigDecimal.ZERO);
//        for (ClassSettlementCard settlementCard : classSettlementCards) {
//            cardSum.setAmt(cardSum.getAmt().add(settlementCard.getAmt()== null ? BigDecimal.ZERO : settlementCard.getAmt()));
//            cardSum.setOrderCount(cardSum.getOrderCount() + settlementCard.getOrderCount());
//            cardSum.setServiceCharge(cardSum.getServiceCharge().add(settlementCard.getServiceCharge() == null ? BigDecimal.ZERO : settlementCard.getServiceCharge()));
//        }
//
//        Map<String, Object> queryGroupByActivitySum = new HashMap<String, Object>();
//        for (Map<String, Object> stringObjectMap : queryGroupByActivity) {
//            // 检查键"order_count"是否存在
//            if (stringObjectMap.containsKey("order_count")) {
//                // 如果queryGroupByActivitySum中已经存在"order_count"键，则将其值与stringObjectMap中的"order_count"值相加
//                // 否则，将stringObjectMap中的"order_count"值直接放入queryGroupByActivitySum中
//                queryGroupByActivitySum.put("order_count", queryGroupByActivitySum.containsKey("order_count")
//                        ? Long.valueOf(queryGroupByActivitySum.get("order_count").toString()) + Long.valueOf(stringObjectMap.get("order_count").toString())
//                        : Long.valueOf(stringObjectMap.get("order_count").toString()));
//            }
//
//            // 检查键"discount_amt"是否存在
//            if (stringObjectMap.containsKey("discount_amt")) {
//                // 如果queryGroupByActivitySum中已经存在"discount_amt"键，则将其值与stringObjectMap中的"discount_amt"值相加
//                // 否则，将stringObjectMap中的"discount_amt"值直接放入queryGroupByActivitySum中
//                queryGroupByActivitySum.put("discount_amt", queryGroupByActivitySum.containsKey("discount_amt")
//                        ? Double.valueOf(queryGroupByActivitySum.get("discount_amt").toString()) + Double.valueOf(stringObjectMap.get("discount_amt").toString())
//                        : Double.valueOf(stringObjectMap.get("discount_amt").toString()));
//            }
//
//            // 检查键"order_liters"是否存在
//            if (stringObjectMap.containsKey("order_liters")) {
//                // 如果queryGroupByActivitySum中已经存在"order_liters"键，则将其值与stringObjectMap中的"order_liters"值相加
//                // 否则，将stringObjectMap中的"order_liters"值直接放入queryGroupByActivitySum中
//                queryGroupByActivitySum.put("order_liters", queryGroupByActivitySum.containsKey("order_liters")
//                        ? Double.valueOf(queryGroupByActivitySum.get("order_liters").toString()) + Double.valueOf(stringObjectMap.get("order_liters").toString())
//                        : Double.valueOf(stringObjectMap.get("order_liters").toString()));
//            }
//
//            // 检查键"receivable_amt"是否存在
//            if (stringObjectMap.containsKey("receivable_amt")) {
//                // 如果queryGroupByActivitySum中已经存在"receivable_amt"键，则将其值与stringObjectMap中的"receivable_amt"值相加
//                // 否则，将stringObjectMap中的"receivable_amt"值直接放入queryGroupByActivitySum中
//                queryGroupByActivitySum.put("receivable_amt", queryGroupByActivitySum.containsKey("receivable_amt")
//                        ? Double.valueOf(queryGroupByActivitySum.get("receivable_amt").toString()) + Double.valueOf(stringObjectMap.get("receivable_amt").toString())
//                        : Double.valueOf(stringObjectMap.get("receivable_amt").toString()));
//            }
//
//            if (stringObjectMap.containsKey("amt")) {
//                queryGroupByActivitySum.put("amt", queryGroupByActivitySum.containsKey("amt")
//                        ? Double.valueOf(queryGroupByActivitySum.get("amt").toString()) + Double.valueOf(stringObjectMap.get("amt").toString())
//                        : Double.valueOf(stringObjectMap.get("amt").toString()));
//            }
//        }
////        消费合计应收：receivableAmt (应收金额)
////        短款：moreAmt (短款金额)
////        消费合计实收：amt (实收金额)
////        优惠券合计金额：discountCouponAmt (优惠券优惠金额)
////        充值实收合计金额：(写死为0)（未提供充值实收合计金额字段）
////        立减合计金额：discountAmt (立减优惠金额)
////        客户退款合计金额：refundAmt (退款金额)
////        消耗积分：score (消耗积分)
////        备注：note (备注)
////        提现总金额：totalWithdrawalAmount (提现总金额)
//        resultMap.put("querySummaryByClassNo", querySummaryByClassNo);
//        resultMap.put("cardSum", cardSum);
//        resultMap.put("queryGroupByOil", queryGroupByOil);
//        resultMap.put("queryGroupByPayType", queryGroupByPayType);
//        List<ClassSettlementCard> queryGroupByRecharge = new ArrayList<ClassSettlementCard>();
//        ClassSettlementCard dkqClassSettlementCard = new ClassSettlementCard();
//        dkqClassSettlementCard.setPayType("dkq");
//        dkqClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
//        dkqClassSettlementCard.setAmt(BigDecimal.ZERO);
//        dkqClassSettlementCard.setOrderCount(0L);
//        Map<String, Object> dzkCus = null;
//        if (queryGroupByPayType != null && !queryGroupByPayType.isEmpty()) {
//            for (Map<String, Object> obj : queryGroupByPayType) {
//                if (obj.containsKey("pay_type") && obj.get("pay_type").equals("dkq")) {
//                    dkqClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
//                    double amtDouble = (obj.get("amt") != null) ? (double) obj.get("amt") : 0.0;
//                    BigDecimal amt = BigDecimal.valueOf(amtDouble);
//                    dkqClassSettlementCard.setAmt(amt); // 强制类型转换
//                    Long order_count = (obj.get("order_count") != null) ? ((BigDecimal) obj.get("order_count")).longValue() : 0L;
//                    dkqClassSettlementCard.setOrderCount(order_count); // 强制类型转换
//                }
//                if (obj.containsKey("pay_type") && obj.get("pay_type").equals("dzk")) {
//                    dzkCus = obj;
//                }
//            }
//        }
//        queryGroupByRecharge.add(dkqClassSettlementCard);
//        List<ClassSettlementCard> classSettlementDZK = settDto.getSettlementCardList();
//        for(ClassSettlementCard classSettlementDZKItem:classSettlementDZK){
//            if(classSettlementDZKItem.getPayType().equals("msub")){
//                ClassSettlementCard newClassSettlementCard = new ClassSettlementCard();
//                newClassSettlementCard.setPayType("msub");
//                newClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
//                newClassSettlementCard.setAmt(MathUtil.add(classSettlementDZKItem.getAmt(),classSettlementDZKItem.getGiveAmt()));
//                newClassSettlementCard.setOrderCount(classSettlementDZKItem.getOrderCount());
//                queryGroupByRecharge.add(newClassSettlementCard);
//            }
////            else if(classSettlementDZKItem.getPayType().equals("")){
////                ClassSettlementCard newClassSettlementCard = new ClassSettlementCard();
////                newClassSettlementCard.setPayType("");
////                newClassSettlementCard.setGiveAmt(classSettlementDZKItem.getGiveAmt());
////                newClassSettlementCard.setAmt(classSettlementDZKItem.getAmt());
////                newClassSettlementCard.setOrderCount(classSettlementDZKItem.getOrderCount());
////                queryGroupByRecharge.add(newClassSettlementCard);
////            }
//        }
//        if (dzkCus != null) {
//            ClassSettlementCard newClassSettlementCard = new ClassSettlementCard();
//            newClassSettlementCard.setPayType("");
//            double discountAmtDouble = (dzkCus.get("discount_amt") != null) ? (double) dzkCus.get("discount_amt") : 0d;
//            double discountCouponAmtDouble = (dzkCus.get("discount_coupon_amt") != null) ? (double) dzkCus.get("discount_coupon_amt") : 0d;
//            newClassSettlementCard.setGiveAmt(BigDecimal.valueOf(discountAmtDouble).add(BigDecimal.valueOf(discountCouponAmtDouble)));
//            newClassSettlementCard.setAmt((dzkCus.get("amt") != null) ? BigDecimal.valueOf((double) dzkCus.get("amt")) : BigDecimal.ZERO);
//            newClassSettlementCard.setOrderCount((dzkCus.get("order_count") != null) ? ((BigDecimal) dzkCus.get("order_count")).longValue() : 0L);
//            queryGroupByRecharge.add(newClassSettlementCard);
//        }
////        充值根据加油员分类充值用户
//        resultMap.put("changeClassSettlement4User", changeClassSettlement4User);
//        resultMap.put("queryGroupByRecharge", queryGroupByRecharge);
//        resultMap.put("classSettlementCards", classSettlementCards);
//        resultMap.put("classSettlementCardsGroupByCardType", classSettlementCardsGroupByCardType);
//        resultMap.put("classSettlementCardRechargeCardType", classSettlementCardRechargeCardType);
//        resultMap.put("queryGroupByOilGun", queryGroupByOilGun);
////        resultMap.put("newQueryGroupByOilGun", newQueryGroupByOilGun);
//        resultMap.put("queryGroupByActivity", queryGroupByActivity);
//        resultMap.put("queryGroupByActivitySum", queryGroupByActivitySum);
//        resultMap.put("listDetail4User", listDetail4User);
//        if (querySummaryByClassNo != null && !querySummaryByClassNo.isEmpty()) {
//            // querySummaryByClassNo 不为空时的处理逻辑
//            BigDecimal sumPrice = querySummaryByClassNo != null && !querySummaryByClassNo.isEmpty() ? querySummaryByClassNo.get(0).getSumPrice() : BigDecimal.ZERO;
//            BigDecimal cardSumAmt = cardSum != null && cardSum.getAmt() != null ? cardSum.getAmt() : BigDecimal.ZERO;
//            if (sumPrice != null) {
//                BigDecimal accountAmt = sumPrice.add(cardSumAmt);
//                resultMap.put("accountAmt", accountAmt);
//            } else {
//                resultMap.put("accountAmt", cardSumAmt);
//            }
//            if (querySummaryByClassNo.get(0).getServiceCharge() != null) {
//                BigDecimal serviceCharge = querySummaryByClassNo != null && !querySummaryByClassNo.isEmpty() && querySummaryByClassNo.get(0).getServiceCharge() != null ? querySummaryByClassNo.get(0).getServiceCharge() : BigDecimal.ZERO;
//                BigDecimal cardSumServiceCharge = cardSum != null && cardSum.getServiceCharge() != null ? cardSum.getServiceCharge() : BigDecimal.ZERO;
//                if (serviceCharge != null) {
//                    BigDecimal totalServiceCharge = serviceCharge.add(cardSumServiceCharge);
//                    resultMap.put("serviceCharge", totalServiceCharge);
//                } else {
//                    resultMap.put("serviceCharge", cardSumServiceCharge);
//                }
//            } else {
//                resultMap.put("serviceCharge", BigDecimal.ZERO);
//            }
//        } else {
//            resultMap.put("accountAmt", BigDecimal.ZERO);
//            resultMap.put("serviceCharge", BigDecimal.ZERO);
//        }
//        return AjaxResult.success(resultMap);
//    }
//
//    @Override
//    public AjaxResult getEmployeeInfoForOrder(String createStartTime,
//                                      String createEndTime,
//                                      String oilPersonnelId) {
//
//        if (StringUtils.isBlank(oilPersonnelId)) {
//            return AjaxResult.error("查看班结详情没有加油员");
//        }
//        Map<String, Object> resultMap = new HashMap<String, Object>();
//        Map<String, Object> queryMap = new HashMap<String, Object>();
//        queryMap.put("createStartTime", createStartTime);
//        queryMap.put("createEndTime", createEndTime);
//        queryMap.put("oilPersonnelId", oilPersonnelId);
//        // 根据班结编号查询班结摘要信息
//        List<ClassSettlement> querySummaryByClassNo = this.employeeQuerySummaryByClassNoForOrder(queryMap);
//// 根据油品分组查询统计信息
//        List<Map<String, Object>> queryGroupByOil = this.employeeQueryGroupByOilForOrder(queryMap);
//        Iterator<Map<String, Object>> iterator = queryGroupByOil.iterator();
//        while (iterator.hasNext()) {
//            Map<String, Object> map = iterator.next();
//            if (!map.containsKey("oil_name")) {
//                iterator.remove();
//            }
//        }
//        Map<String, Object> allOil = new HashMap<String, Object>();
//        BigDecimal orderLiterSum = BigDecimal.ZERO;
//        BigDecimal receivableAmtSum = BigDecimal.ZERO;
//        BigDecimal amtSum = BigDecimal.ZERO;
//        BigDecimal discountAmtSum = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSum = BigDecimal.ZERO;
//        BigDecimal orderCountSum = BigDecimal.ZERO;
//        for (Map<String, Object> itemOil : queryGroupByOil) {
//            Object orderLiterObj = itemOil.get("order_liters");
//            double orderLiterDouble = (orderLiterObj != null) ? (double) orderLiterObj : 0.0;
//            BigDecimal orderLiter = BigDecimal.valueOf(orderLiterDouble);
//            if (orderLiter != null) {
//                orderLiterSum = orderLiterSum.add(orderLiter);
//            }
//
//            Object receivableAmtObj = itemOil.get("receivable_amt");
//            double receivableAmtDouble = (receivableAmtObj != null) ? (double) receivableAmtObj : 0.0;
//            BigDecimal receivableAmt = BigDecimal.valueOf(receivableAmtDouble);
//            if (receivableAmt != null) {
//                receivableAmtSum = receivableAmtSum.add(receivableAmt);
//            }
//
//            Object amtObj = itemOil.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSum = amtSum.add(amt);
//            }
//
//            Object discountAmtObj = itemOil.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSum = discountAmtSum.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemOil.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSum = discountCouponAmtSum.add(discountCouponAmt);
//            }
//            Object orderCountObj = itemOil.get("order_count");
//            BigDecimal orderCount = (orderCountObj != null) ? (BigDecimal) orderCountObj : BigDecimal.ZERO;
//            BigDecimal orderCountBigDecimal = orderCount;
//            if (orderCountBigDecimal != null) {
//                orderCountSum = orderCountSum.add(orderCountBigDecimal);
//            }
//        }
//        allOil.put("oil_name", "合计");
//        allOil.put("order_liters", orderLiterSum);
//        allOil.put("receivable_amt", receivableAmtSum);
//        allOil.put("amt", amtSum);
//        allOil.put("discount_amt", discountAmtSum);
//        allOil.put("discount_coupon_amt", discountCouponAmtSum);
//        allOil.put("order_count", orderCountSum);
//        queryGroupByOil.add(allOil);
//
//// 根据支付方式分组查询统计信息
//        List<Map<String, Object>> queryGroupByPayType = this.employeeQueryGroupByPayTypeForOrder(queryMap);
//        Iterator<Map<String, Object>> iterator3 = queryGroupByPayType.iterator();
//        while (iterator3.hasNext()) {
//            Map<String, Object> map = iterator3.next();
//            if (!map.containsKey("pay_type")) {
//                iterator3.remove();
//            }
//        }
//        Map<String, Object> allPayType = new HashMap<>();
//        BigDecimal amtSum2 = BigDecimal.ZERO;
//        BigDecimal refundAmtSum2 = BigDecimal.ZERO;
//        BigDecimal discountAmtSum2 = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSum2 = BigDecimal.ZERO;
//
//        for (Map<String, Object> itemPayType : queryGroupByPayType) {
//            Object amtObj = itemPayType.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSum2 = amtSum2.add(amt);
//            }
//
//            Object refundAmtObj = itemPayType.get("refund_amt");
//            double refundAmtDouble = (refundAmtObj != null) ? (double) refundAmtObj : 0.0;
//            BigDecimal refundAmt = BigDecimal.valueOf(refundAmtDouble);
//            if (refundAmt != null) {
//                refundAmtSum2 = refundAmtSum2.add(refundAmt);
//            }
//
//            Object discountAmtObj = itemPayType.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSum2 = discountAmtSum2.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemPayType.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSum2 = discountCouponAmtSum2.add(discountCouponAmt);
//            }
//        }
//
//        allPayType.put("pay_type", "合计");
//        allPayType.put("amt", amtSum2);
//        allPayType.put("refund_amt", refundAmtSum2);
//        allPayType.put("discount_amt", discountAmtSum2);
//        allPayType.put("discount_coupon_amt", discountCouponAmtSum2);
//
//        queryGroupByPayType.add(allPayType);
//
//// 根据油枪分组查询统计信息
//        List<Map<String, Object>> queryGroupByOilGun = this.employeeQueryGroupByOilGunForOrder(queryMap);
//        Iterator<Map<String, Object>> iterator2 = queryGroupByOilGun.iterator();
//        while (iterator2.hasNext()) {
//            Map<String, Object> map = iterator2.next();
//            if (!map.containsKey("oil_gun")) {
//                iterator2.remove();
//            }
//        }
//        // 油机数据
//        List<OilEngineDto> newQueryGroupByOilGun = classSettlementMapper.employeeClassSettlementOilEngineSum(queryMap);
//        List<String> oilGunListA = new ArrayList<>();
//        List<String> oilGunListB = new ArrayList<>();
//        if (queryGroupByOilGun.size() > 0 && newQueryGroupByOilGun.size() > 0) {
//            for (Map<String, Object> map : queryGroupByOilGun) {
//                String oilGun = map.get("oil_gun").toString();
//                oilGunListA.add(oilGun); // 存储a列表的油枪数据
//                oilGunListB.clear();
//                for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                    oilGunListB.add(oilEngineDto.getOilGun());
//                    if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//                        map.put("oil_price", oilEngineDto.getOilPrice());
//                        map.put("order_liters", oilEngineDto.getOrderLiters());
//                        map.put("oil_name", oilEngineDto.getOilName());
//                        map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                        map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                    }
//                }
//            }
//            List<String> difference = new ArrayList<>();
//            for (String value : oilGunListB) {
//                if (!oilGunListA.contains(value)) {
//                    difference.add(value);
//                }
//            }
//            for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                for (String oilGun : difference) {
//
//                    if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//
//                        Map<String, Object> map = new HashMap<>();
//                        map.put("oil_gun", oilEngineDto.getOilGun());
//                        map.put("oil_price", oilEngineDto.getOilPrice());
//                        map.put("order_liters", oilEngineDto.getOrderLiters());
//                        map.put("oil_name", oilEngineDto.getOilName());
//                        map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                        map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                        queryGroupByOilGun.add(map);
//                    }
//                }
//            }
//
//        } else if (queryGroupByOilGun.size() == 0 && newQueryGroupByOilGun.size() > 0) {
//            for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                if (oilEngineDto != null && oilEngineDto.getOilGun() != null) {
//                    Map<String, Object> map = new HashMap<>();
//                    map.put("oil_gun", oilEngineDto.getOilGun());
//                    map.put("oil_price", oilEngineDto.getOilPrice());
//                    map.put("order_liters", oilEngineDto.getOrderLiters());
//                    map.put("oil_name", oilEngineDto.getOilName());
//                    map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                    map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                    queryGroupByOilGun.add(map);
//
//                }
//            }
//        }
//
//// 根据活动分组查询统计信息
////        List<Map<String, Object>> queryGroupByActivity = this.queryGroupByActivityForOrder(queryMap);
//
//// 根据员工方式查询统计信息
//        List<Map<String, Object>> listDetail4User = this.employeeSelectClassSettlement4User4POSListForOrder(queryMap);
//        Iterator<Map<String, Object>> iterator4 = listDetail4User.iterator();
//        while (iterator4.hasNext()) {
//            Map<String, Object> map = iterator4.next();
//            if (!map.containsKey("oil_name")) {
//                iterator4.remove();
//            }
//        }
//        Map<String, Object> allDetail4User = new HashMap<String, Object>();
//        BigDecimal orderLiterSumForUser = BigDecimal.ZERO;
//        BigDecimal receivableAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal amtSumForUser = BigDecimal.ZERO;
//        BigDecimal discountAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal refundAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal orderCountSumForUser = BigDecimal.ZERO;
//        BigDecimal moreAmtSumForUser = BigDecimal.ZERO;
//
//        for (Map<String, Object> itemOil : listDetail4User) {
//            Object orderLiterObj = itemOil.get("order_liters");
//            double orderLiterDouble = (orderLiterObj != null) ? (double) orderLiterObj : 0.0;
//            BigDecimal orderLiter = BigDecimal.valueOf(orderLiterDouble);
//            if (orderLiter != null) {
//                orderLiterSumForUser = orderLiterSumForUser.add(orderLiter);
//            }
//
//            Object receivableAmtObj = itemOil.get("receivable_amt");
//            double receivableAmtDouble = (receivableAmtObj != null) ? (double) receivableAmtObj : 0.0;
//            BigDecimal receivableAmt = BigDecimal.valueOf(receivableAmtDouble);
//            if (receivableAmt != null) {
//                receivableAmtSumForUser = receivableAmtSumForUser.add(receivableAmt);
//            }
//
//            Object amtObj = itemOil.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSumForUser = amtSumForUser.add(amt);
//            }
//
//            Object discountAmtObj = itemOil.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSumForUser = discountAmtSumForUser.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemOil.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSumForUser = discountCouponAmtSumForUser.add(discountCouponAmt);
//            }
//
//            Object refundAmtObj = itemOil.get("refund_amt");
//            double refundAmtDouble = (refundAmtObj != null) ? (double) refundAmtObj : 0.0;
//            BigDecimal refundAmt = BigDecimal.valueOf(refundAmtDouble);
//            if (refundAmt != null) {
//                refundAmtSumForUser = refundAmtSumForUser.add(refundAmt);
//            }
//
//            Object orderCountObj = itemOil.get("order_count");
//            BigDecimal orderCount = (orderCountObj != null) ? (BigDecimal) orderCountObj : BigDecimal.ZERO;
//            BigDecimal orderCountBigDecimal = orderCount;
//            if (orderCountBigDecimal != null) {
//                orderCountSumForUser = orderCountSumForUser.add(orderCountBigDecimal);
//            }
//
//            Object moreAmtObj = itemOil.get("more_amt");
//            double moreAmtDouble = (moreAmtObj != null) ? (double) moreAmtObj : 0.0;
//            BigDecimal moreAmt = BigDecimal.valueOf(moreAmtDouble);
//            if (moreAmt != null) {
//                moreAmtSumForUser = moreAmtSumForUser.add(moreAmt);
//            }
//        }
//
//        allDetail4User.put("oil_personnel_name", "合计");
//        allDetail4User.put("order_liters", orderLiterSumForUser);
//        allDetail4User.put("receivable_amt", receivableAmtSumForUser);
//        allDetail4User.put("amt", amtSumForUser);
//        allDetail4User.put("discount_amt", discountAmtSumForUser);
//        allDetail4User.put("discount_coupon_amt", discountCouponAmtSumForUser);
//        allDetail4User.put("refund_amt", refundAmtSumForUser);
//        allDetail4User.put("order_count", orderCountSumForUser);
//        allDetail4User.put("more_amt", moreAmtSumForUser);
//
//        listDetail4User.add(allDetail4User);
//// 根据查询条件查询用户的班结详细信息列表
////        ClassSettlementCard classSettlementCard = new ClassSettlementCard();
////        // 确保 createStartTime 不为 null
////        if (createStartTime != null) {
////            // 保留年月日时分秒部分，截取前19个字符
////            String formattedStartTime = createStartTime.substring(0, 19);
////            classSettlementCard.setCreateStartTime(formattedStartTime);
////
////        }
////// 确保 createEndTime 不为 null
////        if (createEndTime != null) {
////            // 保留年月日时分秒部分，截取前19个字符
////            String formattedEndTime = createEndTime.substring(0, 19);
////            classSettlementCard.setCreateEndTime(formattedEndTime);
////
////        }
////        classSettlementCard.setStationId(stationId);
////        List<ClassSettlementCard> classSettlementCards = classSettlementCardService.queryGroupByPayTypeForOrder(classSettlementCard);
//// 根据支付方式分组查询结算卡信息列表
////        List<ClassSettlementCard> classSettlementCardsGroupByCardType = classSettlementCardService.queryGroupByCardTypeForOrder(classSettlementCard);
//// 根据卡类型分组查询结算卡信息列表
////        List<ClassSettlementCard> classSettlementCardRechargeCardType = classSettlementCardService.queryGroupByRechargeCardTypeForOrder(classSettlementCard);
//        // 根据充值卡类型分组查询结算卡信息列表
////        ClassSettlementCard cardSum = new ClassSettlementCard();
////        cardSum.setAmt(BigDecimal.ZERO);
////        cardSum.setOrderCount(0L);
////        cardSum.setServiceCharge(BigDecimal.ZERO);
////        for (ClassSettlementCard settlementCard : classSettlementCards) {
////            cardSum.setAmt(cardSum.getAmt().add(settlementCard.getAmt()));
////            cardSum.setOrderCount(cardSum.getOrderCount() + settlementCard.getOrderCount());
////            cardSum.setServiceCharge(cardSum.getServiceCharge().add(settlementCard.getServiceCharge() == null ? BigDecimal.ZERO : settlementCard.getServiceCharge()));
////        }
//
////        Map<String, Object> queryGroupByActivitySum = new HashMap<String, Object>();
////        for (Map<String, Object> stringObjectMap : queryGroupByActivity) {
////            // 检查键"order_count"是否存在
////            if (stringObjectMap.containsKey("order_count")) {
////                // 如果queryGroupByActivitySum中已经存在"order_count"键，则将其值与stringObjectMap中的"order_count"值相加
////                // 否则，将stringObjectMap中的"order_count"值直接放入queryGroupByActivitySum中
////                queryGroupByActivitySum.put("order_count", queryGroupByActivitySum.containsKey("order_count")
////                        ? Long.valueOf(queryGroupByActivitySum.get("order_count").toString()) + Long.valueOf(stringObjectMap.get("order_count").toString())
////                        : Long.valueOf(stringObjectMap.get("order_count").toString()));
////            }
////
////            // 检查键"discount_amt"是否存在
////            if (stringObjectMap.containsKey("discount_amt")) {
////                // 如果queryGroupByActivitySum中已经存在"discount_amt"键，则将其值与stringObjectMap中的"discount_amt"值相加
////                // 否则，将stringObjectMap中的"discount_amt"值直接放入queryGroupByActivitySum中
////                queryGroupByActivitySum.put("discount_amt", queryGroupByActivitySum.containsKey("discount_amt")
////                        ? Double.valueOf(queryGroupByActivitySum.get("discount_amt").toString()) + Double.valueOf(stringObjectMap.get("discount_amt").toString())
////                        : Double.valueOf(stringObjectMap.get("discount_amt").toString()));
////            }
////
////            // 检查键"order_liters"是否存在
////            if (stringObjectMap.containsKey("order_liters")) {
////                // 如果queryGroupByActivitySum中已经存在"order_liters"键，则将其值与stringObjectMap中的"order_liters"值相加
////                // 否则，将stringObjectMap中的"order_liters"值直接放入queryGroupByActivitySum中
////                queryGroupByActivitySum.put("order_liters", queryGroupByActivitySum.containsKey("order_liters")
////                        ? Double.valueOf(queryGroupByActivitySum.get("order_liters").toString()) + Double.valueOf(stringObjectMap.get("order_liters").toString())
////                        : Double.valueOf(stringObjectMap.get("order_liters").toString()));
////            }
////
////            // 检查键"receivable_amt"是否存在
////            if (stringObjectMap.containsKey("receivable_amt")) {
////                // 如果queryGroupByActivitySum中已经存在"receivable_amt"键，则将其值与stringObjectMap中的"receivable_amt"值相加
////                // 否则，将stringObjectMap中的"receivable_amt"值直接放入queryGroupByActivitySum中
////                queryGroupByActivitySum.put("receivable_amt", queryGroupByActivitySum.containsKey("receivable_amt")
////                        ? Double.valueOf(queryGroupByActivitySum.get("receivable_amt").toString()) + Double.valueOf(stringObjectMap.get("receivable_amt").toString())
////                        : Double.valueOf(stringObjectMap.get("receivable_amt").toString()));
////            }
////
////            if (stringObjectMap.containsKey("amt")) {
////                queryGroupByActivitySum.put("amt", queryGroupByActivitySum.containsKey("amt")
////                        ? Double.valueOf(queryGroupByActivitySum.get("amt").toString()) + Double.valueOf(stringObjectMap.get("amt").toString())
////                        : Double.valueOf(stringObjectMap.get("amt").toString()));
////            }
////        }
////        消费合计应收：receivableAmt (应收金额)
////        短款：moreAmt (短款金额)
////        消费合计实收：amt (实收金额)
////        优惠券合计金额：discountCouponAmt (优惠券优惠金额)
////        充值实收合计金额：(写死为0)（未提供充值实收合计金额字段）
////        立减合计金额：discountAmt (立减优惠金额)
////        客户退款合计金额：refundAmt (退款金额)
////        消耗积分：score (消耗积分)
////        备注：note (备注)
////        提现总金额：totalWithdrawalAmount (提现总金额)
//        resultMap.put("querySummaryByClassNo", querySummaryByClassNo);
//        resultMap.put("cardSum", null);
//        resultMap.put("queryGroupByOil", queryGroupByOil);  // 消费-油品汇总
//        resultMap.put("queryGroupByPayType", queryGroupByPayType);  // 消费-支付方式汇总
//
//        List<ClassSettlementCard> queryGroupByRecharge = new ArrayList<ClassSettlementCard>();
//        // 会员卡-消费汇总  实体卡支付
//        ClassSettlementCard dkqClassSettlementCard = new ClassSettlementCard();
//        dkqClassSettlementCard.setPayType("dkq");
//        dkqClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
//        dkqClassSettlementCard.setAmt(BigDecimal.ZERO);
//        dkqClassSettlementCard.setOrderCount(0L);
//        if (queryGroupByPayType != null && !queryGroupByPayType.isEmpty()) {
//            for (Map<String, Object> obj : queryGroupByPayType) {
//                if (obj.containsKey("pay_type") && obj.get("pay_type").equals("dkq")) {
//                    dkqClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
//                    double amtDouble = (obj.get("amt") != null) ? (double) obj.get("amt") : 0.0;
//                    BigDecimal amt = BigDecimal.valueOf(amtDouble);
//                    dkqClassSettlementCard.setAmt(amt); // 强制类型转换
//                    Long order_count = (obj.get("order_count") != null) ? ((BigDecimal) obj.get("order_count")).longValue() : 0L;
//                    dkqClassSettlementCard.setOrderCount(order_count); // 强制类型转换
//                }
//            }
//        }
//        queryGroupByRecharge.add(dkqClassSettlementCard);
//
//        // 手动扣减
////        List<ClassSettlementCard> classSettlementDZK = settDto.getSettlementCardList();
////        for(ClassSettlementCard classSettlementDZKItem:classSettlementDZK){
////            if(classSettlementDZKItem.getPayType().equals("msub")){
////                ClassSettlementCard newClassSettlementCard = new ClassSettlementCard();
////                newClassSettlementCard.setPayType("msub");
////                // 员工权限看不到手动扣减
////                newClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
////                newClassSettlementCard.setAmt(BigDecimal.ZERO);
////                newClassSettlementCard.setOrderCount(0l);
////                queryGroupByRecharge.add(newClassSettlementCard);
////            }else if(classSettlementDZKItem.getPayType().equals("")){
////                ClassSettlementCard newClassSettlementCard = new ClassSettlementCard();
////                newClassSettlementCard.setPayType("");
////                newClassSettlementCard.setGiveAmt(classSettlementDZKItem.getGiveAmt());
////                newClassSettlementCard.setAmt(classSettlementDZKItem.getAmt());
////                newClassSettlementCard.setOrderCount(classSettlementDZKItem.getOrderCount());
////                queryGroupByRecharge.add(newClassSettlementCard);
////            }
////        }
//
//        // 员工权限 手动扣减没有生产订单，无法和员工关联，统计不了  默认设置为0
//        ClassSettlementCard newClassSettlementCard = new ClassSettlementCard();
//        newClassSettlementCard.setPayType("msub");
//        newClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
//        newClassSettlementCard.setAmt(BigDecimal.ZERO);
//        newClassSettlementCard.setOrderCount(0l);
//        queryGroupByRecharge.add(newClassSettlementCard);
//
//        // 会员卡支付（电子卡消费）
//        Map<String, Object> dzkMap = classSettlementMapper.employeeSelectDzkPayOrder(queryMap);
//        if(dzkMap != null && !dzkMap.isEmpty()){
//            ClassSettlementCard newDzkClassSettlementCard = new ClassSettlementCard();
//            newClassSettlementCard.setPayType("");
//            Object orderCountObj = dzkMap.get("order_count");
//            newDzkClassSettlementCard.setOrderCount((orderCountObj != null) ? (Long) orderCountObj : 0l);
//
//            Double amtObj = (Double) dzkMap.get("amt");
//            BigDecimal amt = (amtObj != null) ? new BigDecimal(amtObj) : BigDecimal.ZERO;
//            newDzkClassSettlementCard.setAmt(amt);
//
//            Double discountAmtObj = (Double) dzkMap.get("discount_amt");
//            BigDecimal discountAmt = (discountAmtObj != null) ? new BigDecimal(discountAmtObj) : BigDecimal.ZERO;
//
//            Double discountCouponAmtObj = (Double) dzkMap.get("discount_coupon_amt");
//            BigDecimal discountCouponAmt = (discountCouponAmtObj != null) ? new BigDecimal(discountCouponAmtObj) : BigDecimal.ZERO;
//            newDzkClassSettlementCard.setGiveAmt(discountAmt.add(discountCouponAmt));
//
//            queryGroupByRecharge.add(newDzkClassSettlementCard);
//        }
//
//        resultMap.put("queryGroupByRecharge", queryGroupByRecharge);  // 会员卡-消费汇总
//        resultMap.put("classSettlementCards", null);
//        resultMap.put("classSettlementCardsGroupByCardType", null);
//        resultMap.put("classSettlementCardRechargeCardType", null);
//        resultMap.put("queryGroupByOilGun", queryGroupByOilGun); // 消费-油枪汇总
////        resultMap.put("newQueryGroupByOilGun", newQueryGroupByOilGun);
//        resultMap.put("queryGroupByActivity", null);
//        resultMap.put("queryGroupByActivitySum", null);
//        resultMap.put("listDetail4User", listDetail4User);  // 消费-员工方式汇总
//        if (querySummaryByClassNo != null && !querySummaryByClassNo.isEmpty()) {
//            // querySummaryByClassNo 不为空时的处理逻辑
//            BigDecimal sumPrice = querySummaryByClassNo != null && !querySummaryByClassNo.isEmpty() ? querySummaryByClassNo.get(0).getSumPrice() : BigDecimal.ZERO;
////            BigDecimal cardSumAmt = cardSum != null && cardSum.getAmt() != null ? cardSum.getAmt() : BigDecimal.ZERO;
//            if (sumPrice != null) {
////                BigDecimal accountAmt = sumPrice.add(cardSumAmt);
//                resultMap.put("accountAmt", BigDecimal.ZERO);
//            } else {
//                resultMap.put("accountAmt", BigDecimal.ZERO);
//            }
//            if (querySummaryByClassNo.get(0).getServiceCharge() != null) {
//                BigDecimal serviceCharge = querySummaryByClassNo != null && !querySummaryByClassNo.isEmpty() && querySummaryByClassNo.get(0).getServiceCharge() != null ? querySummaryByClassNo.get(0).getServiceCharge() : BigDecimal.ZERO;
////                BigDecimal cardSumServiceCharge = cardSum != null && cardSum.getServiceCharge() != null ? cardSum.getServiceCharge() : BigDecimal.ZERO;
//                if (serviceCharge != null) {
////                    BigDecimal totalServiceCharge = serviceCharge.add(cardSumServiceCharge);
//                    resultMap.put("serviceCharge", BigDecimal.ZERO);
//                } else {
//                    resultMap.put("serviceCharge", BigDecimal.ZERO);
//                }
//            } else {
//                resultMap.put("serviceCharge", BigDecimal.ZERO);
//            }
//        } else {
//            resultMap.put("accountAmt", BigDecimal.ZERO);
//            resultMap.put("serviceCharge", BigDecimal.ZERO);
//        }
//        return AjaxResult.success(resultMap);
//    }
//
//    /**
//     * 新增班结
//     *
//     * @param classSettlement 班结
//     * @return 结果
//     */
//    @Override
//    public int insertClassSettlement(ClassSettlement classSettlement) {
//        classSettlement.setCreateTime(DateUtils.getNowDate());
//        return classSettlementMapper.insertClassSettlement(classSettlement);
//    }
//
//    /**
//     * 新增日报表
//     *
//     * @param classSettlement 班结
//     * @return 结果
//     */
//    @Override
//    public int insertClassReport(ClassSettlement classSettlement) {
//        classSettlement.setCreateTime(DateUtils.getNowDate());
//        return classSettlementMapper.insertClassReport(classSettlement);
//    }
//
//    /**
//     * 新增日报表
//     *
//     * @param stationId 班结
//     * @return 结果
//     */
//    @Override
//    public int insertBusinessDailyReport(Long stationId) {
//        Map<String, Object> resultMap = new HashMap<String, Object>();
//        SysUser user = new SysUser();
//        user.setUserId(1L);
//        user.setUserName("日报表定时任务");
//        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        SimpleDateFormat datefmt = new SimpleDateFormat("yyyy-MM-dd");
//        SimpleDateFormat simFmtBef = new SimpleDateFormat("yyyyMMdd");
//        SimpleDateFormat simFmtAft = new SimpleDateFormat("HHmm");
//        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("serviceType", "BGS");//班结的时候多维度分组查询
//// 创建一个Calendar对象并将其时间设置为当前时间
//        Calendar calendar = Calendar.getInstance();
//        Date nowDate = calendar.getTime();
//// 通过Calendar对象的add方法将日期减去一天，以获得昨天的日期
//
//
//        calendar.add(Calendar.DAY_OF_MONTH, -1);
//
//// 将Calendar对象的时间设置为0点
//        calendar.set(Calendar.HOUR_OF_DAY, 0);
//        calendar.set(Calendar.MINUTE, 0);
//        calendar.set(Calendar.SECOND, 0);
//        Calendar calendar2 = Calendar.getInstance();
//
//
//
//        calendar2.set(Calendar.HOUR_OF_DAY, 0);
//        calendar2.set(Calendar.MINUTE, 0);
//        calendar2.set(Calendar.SECOND, 0);
//
//        Date today = calendar2.getTime();
//// 获取昨天和今天的日期
//        Date yesterday = calendar.getTime();
//// 格式化昨天和今天的日期为"yyyy-MM-dd HH:mm:ss"的格式
//        String yesterdayString = fmt.format(yesterday);
//        String todayString = fmt.format(today);
//        String nowDateString = datefmt.format(yesterday);
//
//// 将昨天和今天的时间添加到params集合中
//        params.put("createStartTime", yesterdayString);
//        params.put("createEndTime", todayString);
//        params.put("stationId", stationId);
//        BusinessDailyReport businessDailyReport = new BusinessDailyReport();
////        allamt是无效的数据
//        BusinessDailyReport  businessDailyReport2 = classSettlementMapper.selectBusinessDailyReport(params);
//        if(businessDailyReport2!=null){
//            businessDailyReport =businessDailyReport2;
//        }
//        Station station=  stationMapper.selectStationById(stationId);
//        Enterprise enterprise =  enterpriseMapper.selectEnterpriseById(station.getEnterpriseId());
//        businessDailyReport.setStationId(stationId);
//        businessDailyReport.setDate(nowDateString);
//        businessDailyReport.setStationName(station.getStationName());
//        businessDailyReport.setEnterpriseName(enterprise.getEnterpriseName());
//        businessDailyReport.setEnterpriseId(station.getEnterpriseId());
//        List<ClassSettlementCard> classSettlementCards = classSettlementCardService.queryUntreatedData(params);
//        CardClassSettDto settDto = countCardSett(classSettlementCards); // 电子卡交易汇总数据
//        ClassSettlementCard physicalCard = classSettlementMapper.queryPhysicalCard(params);
//        ClassSettlementCard fleetCard = classSettlementMapper.queryFleetCard(params);
//        int integral = classSettlementMapper.queryIntegral(params);
//        int writeOffIntegral = classSettlementMapper.queryWriteOffIntegral(params);
//        ClassSettlementCard superPay = this.querySuperPay(params);
//        ClassSettlementCard forSaleActivity= classSettlementMapper.forSaleActivityAmt(params);
//        ClassSettlementCard refSaleActivity= classSettlementMapper.refSaleActivityAmt(params);
//        BigDecimal posTransactionAmt = (settDto.getTotalAmt() != null) ?  settDto.getTotalAmt() : BigDecimal.ZERO;
//        BigDecimal supTransactionAmt = (superPay.getAmt() != null) ?  superPay.getAmt() : BigDecimal.ZERO;
//        BigDecimal dkqTransactionAmt = (physicalCard.getAmt() != null) ?  physicalCard.getAmt() : BigDecimal.ZERO;
//        BigDecimal cdkTransactionAmt = (fleetCard.getAmt() != null) ?  fleetCard.getAmt()  : BigDecimal.ZERO;
//        BigDecimal supGiftAmt = (superPay.getGiveAmt() != null) ?  superPay.getGiveAmt() : BigDecimal.ZERO;
//        BigDecimal dkqGiftAmt = (physicalCard.getGiveAmt() != null) ?  physicalCard.getGiveAmt() : BigDecimal.ZERO;
//        BigDecimal cdkGiftAmt = (fleetCard.getGiveAmt() != null) ?  fleetCard.getGiveAmt()  : BigDecimal.ZERO;
////虽然写pos但是其实是电子卡的微信和退款
//        BigDecimal posimp = BigDecimal.ZERO;
//        BigDecimal posmsub = BigDecimal.ZERO;
//        BigDecimal poswx = BigDecimal.ZERO;
//        BigDecimal poswxCommission = BigDecimal.ZERO;
//        BigDecimal poswxWithdrawalAmount = BigDecimal.ZERO;
//        BigDecimal posref = BigDecimal.ZERO;
//        BigDecimal posrefCommission = BigDecimal.ZERO;
//        BigDecimal posrefWithdrawalAmount = BigDecimal.ZERO;
//
//
//        BigDecimal forSaleActivityAmt = forSaleActivity.getAmt()!=null?forSaleActivity.getAmt():BigDecimal.ZERO;
//        BigDecimal refSaleActivityAmt = refSaleActivity.getAmt()!=null?refSaleActivity.getAmt():BigDecimal.ZERO;
//        BigDecimal forSaleActivityCom = forSaleActivity.getServiceCharge()!=null?forSaleActivity.getServiceCharge():BigDecimal.ZERO;
//        BigDecimal forSaleActivityWithdrawalAmount = forSaleActivity.getWithdrawalAmount()!=null?forSaleActivity.getWithdrawalAmount():BigDecimal.ZERO;
//        List<ClassSettlementCard>  classSettlementCardL = settDto.getSettlementCardList();
////        MANUAL_ADD("imp","手动增加"),
////     *     MANUAL_SUB("msub","手动扣减"),
////     *     WX_RECHARGE("wx","微信充值"),
////        WX_RECHARGE("pos","pos充值"),
////     *     CONSUME("","电子卡支付"),
////     *     REFUND("ref","充值退款"),*/
//        for (ClassSettlementCard classSettlementCardS:classSettlementCardL){
//            if ( classSettlementCardS.getPayType().equals("imp")){
//                if(classSettlementCardS.getAmt()!=null) {
//                    posimp = posimp.add(classSettlementCardS.getAmt());
//                }
//            }
//            if ( classSettlementCardS.getPayType().equals("msub")){
//                if(classSettlementCardS.getAmt()!=null) {
//                    posmsub = posmsub.add(classSettlementCardS.getAmt());
//                }
//            }
//            if ( classSettlementCardS.getPayType().equals("ref")){
//                if(classSettlementCardS.getAmt()!=null){
//                    posref = posref.add(classSettlementCardS.getAmt());
//                }
//
//            }
//
//        }
//        businessDailyReport.setSaleActivityWxamt(forSaleActivityAmt);
//        businessDailyReport.setWechatConsumption((businessDailyReport.getWechatConsumption()!=null?businessDailyReport.getWechatConsumption():BigDecimal.ZERO));
//       BigDecimal weChatRefund = posref.add(refSaleActivityAmt).add(superPay.getRefundAmount()).add(businessDailyReport.getWechatRefund()!=null?businessDailyReport.getWechatRefund():BigDecimal.ZERO);
//        businessDailyReport.setWechatRefund(weChatRefund);
//        businessDailyReport.setWechatRecharge(settDto.getTotalAmt().add(supTransactionAmt));
//        businessDailyReport.setBackstageRecharge(posimp.subtract(posmsub).add(dkqTransactionAmt).add(cdkTransactionAmt));
//        businessDailyReport.setRechargeGift(settDto.getTotalGiveAmt().add(dkqGiftAmt));
////        businessDailyReport.getScanCodeChannelFee()!=null?businessDailyReport.getScanCodeChannelFee():BigDecimal.ZERO
//        BigDecimal arrivalAmt = (businessDailyReport.getArrivalAmount()!=null?businessDailyReport.getArrivalAmount():BigDecimal.ZERO)
//                .add(settDto.getTotalWithdrawalAmount())
//                .add(superPay.getWithdrawalAmount()!=null?superPay.getWithdrawalAmount():BigDecimal.ZERO).add(forSaleActivityWithdrawalAmount);
//        businessDailyReport.setArrivalAmount(arrivalAmt);
//        BigDecimal scanChannelFee =  settDto.getTotalServiceCharge().add((businessDailyReport.getScanCodeChannelFee()!=null?businessDailyReport.getScanCodeChannelFee():BigDecimal.ZERO)).add(superPay.getServiceCharge()!=null?superPay.getServiceCharge():BigDecimal.ZERO).add(forSaleActivityCom);
//        businessDailyReport.setScanCodeChannelFee(scanChannelFee);
//        businessDailyReport.setAddPoints(BigDecimal.valueOf(integral));
//        businessDailyReport.setDeductPoints(BigDecimal.valueOf(writeOffIntegral));
//        return   classSettlementMapper.insertBusinessDailyReport(businessDailyReport);
//
//    }
//
//    @Override
//    public int insertBusinessDailyReportTest(Long stationId) {
//        Map<String, Object> resultMap = new HashMap<String, Object>();
//        SysUser user = new SysUser();
//        user.setUserId(1L);
//        user.setUserName("日报表定时任务");
//        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        SimpleDateFormat datefmt = new SimpleDateFormat("yyyy-MM-dd");
//        SimpleDateFormat simFmtBef = new SimpleDateFormat("yyyyMMdd");
//        SimpleDateFormat simFmtAft = new SimpleDateFormat("HHmm");
//        Map<String, Object> params = new HashMap<String, Object>();
//        params.put("serviceType", "BGS");//班结的时候多维度分组查询
//// 创建一个Calendar对象并将其时间设置为当前时间
//        Calendar calendar = Calendar.getInstance();
//        Date nowDate = calendar.getTime();
//// 通过Calendar对象的add方法将日期减去一天，以获得昨天的日期
//
//
//
//
//// 将Calendar对象的时间设置为0点
//        calendar.set(Calendar.HOUR_OF_DAY, 0);
//        calendar.set(Calendar.MINUTE, 0);
//        calendar.set(Calendar.SECOND, 0);
//        Calendar calendar2 = Calendar.getInstance();
//
//
//        calendar2.add(Calendar.DAY_OF_MONTH, 1);
//        calendar2.set(Calendar.HOUR_OF_DAY, 0);
//        calendar2.set(Calendar.MINUTE, 0);
//        calendar2.set(Calendar.SECOND, 0);
//
//        Date today = calendar2.getTime();
//// 获取昨天和今天的日期
//        Date yesterday = calendar.getTime();
//// 格式化昨天和今天的日期为"yyyy-MM-dd HH:mm:ss"的格式
//        String yesterdayString = fmt.format(yesterday);
//        String todayString = fmt.format(today);
//        String nowDateString = datefmt.format(yesterday);
//
//// 将昨天和今天的时间添加到params集合中
//        params.put("createStartTime", yesterdayString);
//        params.put("createEndTime", todayString);
//        params.put("stationId", stationId);
//        BusinessDailyReport businessDailyReport = new BusinessDailyReport();
////        allamt是无效的数据
//        BusinessDailyReport  businessDailyReport2 = classSettlementMapper.selectBusinessDailyReport(params);
//        if(businessDailyReport2!=null){
//            businessDailyReport =businessDailyReport2;
//        }
//        Station station=  stationMapper.selectStationById(stationId);
//        Enterprise enterprise =  enterpriseMapper.selectEnterpriseById(station.getEnterpriseId());
//        businessDailyReport.setStationId(stationId);
//        businessDailyReport.setDate(nowDateString);
//        businessDailyReport.setStationName(station.getStationName());
//        businessDailyReport.setEnterpriseName(enterprise.getEnterpriseName());
//        businessDailyReport.setEnterpriseId(station.getEnterpriseId());
//        List<ClassSettlementCard> classSettlementCards = classSettlementCardService.queryUntreatedData(params);
//        CardClassSettDto settDto = countCardSett(classSettlementCards); // 电子卡交易汇总数据
//        ClassSettlementCard physicalCard = classSettlementMapper.queryPhysicalCard(params);
//        ClassSettlementCard fleetCard = classSettlementMapper.queryFleetCard(params);
//        int integral = classSettlementMapper.queryIntegral(params);
//        int writeOffIntegral = classSettlementMapper.queryWriteOffIntegral(params);
//        ClassSettlementCard superPay = this.querySuperPay(params);
//        ClassSettlementCard forSaleActivity= classSettlementMapper.forSaleActivityAmt(params);
//        ClassSettlementCard refSaleActivity= classSettlementMapper.refSaleActivityAmt(params);
//        BigDecimal posTransactionAmt = (settDto.getTotalAmt() != null) ?  settDto.getTotalAmt() : BigDecimal.ZERO;
//        BigDecimal supTransactionAmt = (superPay.getAmt() != null) ?  superPay.getAmt() : BigDecimal.ZERO;
//        BigDecimal dkqTransactionAmt = (physicalCard.getAmt() != null) ?  physicalCard.getAmt() : BigDecimal.ZERO;
//        BigDecimal cdkTransactionAmt = (fleetCard.getAmt() != null) ?  fleetCard.getAmt()  : BigDecimal.ZERO;
//        BigDecimal supGiftAmt = (superPay.getGiveAmt() != null) ?  superPay.getGiveAmt() : BigDecimal.ZERO;
//        BigDecimal dkqGiftAmt = (physicalCard.getGiveAmt() != null) ?  physicalCard.getGiveAmt() : BigDecimal.ZERO;
//        BigDecimal cdkGiftAmt = (fleetCard.getGiveAmt() != null) ?  fleetCard.getGiveAmt()  : BigDecimal.ZERO;
////虽然写pos但是其实是电子卡的微信和退款
//        BigDecimal posimp = BigDecimal.ZERO;
//        BigDecimal posmsub = BigDecimal.ZERO;
//        BigDecimal poswx = BigDecimal.ZERO;
//        BigDecimal poswxCommission = BigDecimal.ZERO;
//        BigDecimal poswxWithdrawalAmount = BigDecimal.ZERO;
//        BigDecimal posref = BigDecimal.ZERO;
//        BigDecimal posrefCommission = BigDecimal.ZERO;
//        BigDecimal posrefWithdrawalAmount = BigDecimal.ZERO;
//
//
//        BigDecimal forSaleActivityAmt = forSaleActivity.getAmt()!=null?forSaleActivity.getAmt():BigDecimal.ZERO;
//        BigDecimal refSaleActivityAmt = refSaleActivity.getAmt()!=null?refSaleActivity.getAmt():BigDecimal.ZERO;
//        BigDecimal forSaleActivityCom = forSaleActivity.getServiceCharge()!=null?forSaleActivity.getServiceCharge():BigDecimal.ZERO;
//        BigDecimal forSaleActivityWithdrawalAmount = forSaleActivity.getWithdrawalAmount()!=null?forSaleActivity.getWithdrawalAmount():BigDecimal.ZERO;
//        List<ClassSettlementCard>  classSettlementCardL = settDto.getSettlementCardList();
////        MANUAL_ADD("imp","手动增加"),
////     *     MANUAL_SUB("msub","手动扣减"),
////     *     WX_RECHARGE("wx","微信充值"),
////        WX_RECHARGE("pos","pos充值"),
////     *     CONSUME("","电子卡支付"),
////     *     REFUND("ref","充值退款"),*/
//        for (ClassSettlementCard classSettlementCardS:classSettlementCardL){
//            if ( classSettlementCardS.getPayType().equals("imp")){
//                if(classSettlementCardS.getAmt()!=null) {
//                    posimp = posimp.add(classSettlementCardS.getAmt());
//                }
//            }
//            if ( classSettlementCardS.getPayType().equals("msub")){
//                if(classSettlementCardS.getAmt()!=null) {
//                    posmsub = posmsub.add(classSettlementCardS.getAmt());
//                }
//            }
//            if ( classSettlementCardS.getPayType().equals("ref")){
//                if(classSettlementCardS.getAmt()!=null){
//                    posref = posref.add(classSettlementCardS.getAmt());
//                }
//
//            }
//
//        }
//        businessDailyReport.setSaleActivityWxamt(forSaleActivityAmt);
//        businessDailyReport.setWechatConsumption((businessDailyReport.getWechatConsumption()!=null?businessDailyReport.getWechatConsumption():BigDecimal.ZERO));
//        BigDecimal weChatRefund = posref.add(refSaleActivityAmt).add(superPay.getRefundAmount()).add(businessDailyReport.getWechatRefund()!=null?businessDailyReport.getWechatRefund():BigDecimal.ZERO);
//        businessDailyReport.setWechatRefund(weChatRefund);
//        businessDailyReport.setWechatRecharge(settDto.getTotalAmt().add(supTransactionAmt));
//        businessDailyReport.setBackstageRecharge(posimp.subtract(posmsub).add(dkqTransactionAmt).add(cdkTransactionAmt));
//        businessDailyReport.setRechargeGift(settDto.getTotalGiveAmt().add(dkqGiftAmt));
////        businessDailyReport.getScanCodeChannelFee()!=null?businessDailyReport.getScanCodeChannelFee():BigDecimal.ZERO
//        BigDecimal arrivalAmt = (businessDailyReport.getArrivalAmount()!=null?businessDailyReport.getArrivalAmount():BigDecimal.ZERO)
//                .add(settDto.getTotalWithdrawalAmount())
//                .add(superPay.getWithdrawalAmount()!=null?superPay.getWithdrawalAmount():BigDecimal.ZERO).add(forSaleActivityWithdrawalAmount);
//        businessDailyReport.setArrivalAmount(arrivalAmt);
//        BigDecimal scanChannelFee =  settDto.getTotalServiceCharge().add((businessDailyReport.getScanCodeChannelFee()!=null?businessDailyReport.getScanCodeChannelFee():BigDecimal.ZERO)).add(superPay.getServiceCharge()!=null?superPay.getServiceCharge():BigDecimal.ZERO).add(forSaleActivityCom);
//        businessDailyReport.setScanCodeChannelFee(scanChannelFee);
//        businessDailyReport.setAddPoints(BigDecimal.valueOf(integral));
//        businessDailyReport.setDeductPoints(BigDecimal.valueOf(writeOffIntegral));
//        return   classSettlementMapper.insertBusinessDailyReport(businessDailyReport);
//
//    }
//
//    @Override
//    public CardClassSettDto countCardSett(List<ClassSettlementCard> settlementCardList){
//        Map<CardRecordType,ClassSettlementCard> map = new HashMap<>();
//        // 根据payType进行分组统计
//        for (ClassSettlementCard settlementCard : settlementCardList) {
//            if (!org.apache.commons.lang3.StringUtils.equals("dzk",settlementCard.getRechargeType())) {
//                continue;
//            }
//            CardRecordType payType = CardRecordType.getByKey(settlementCard.getPayType(),CardRecordType.CONSUME);
//            ClassSettlementCard settlement = map.get(payType);
//            if (settlement == null) {
//                settlement = new ClassSettlementCard();
//                settlement.setPayType(payType.getKey());
//                settlement.setAmt(BigDecimal.ZERO);
//                settlement.setOrderCount(0L);
//                settlement.setServiceCharge(BigDecimal.ZERO);
//                settlement.setGiveAmt(BigDecimal.ZERO);
//                map.put(payType,settlement);
//            }
//            settlement.setAmt(MathUtil.add(settlement.getAmt(),settlementCard.getAmt()));
//            settlement.setOrderCount(MathUtil.add(settlement.getOrderCount(),settlementCard.getOrderCount()));
//            settlement.setServiceCharge(MathUtil.add(settlement.getServiceCharge(),settlementCard.getServiceCharge()==null?null:settlementCard.getServiceCharge().setScale(2,RoundingMode.HALF_UP)));
//            settlement.setGiveAmt(MathUtil.add(settlement.getGiveAmt(),settlementCard.getGiveAmt()));
//        }
//        CardClassSettDto settDto = new CardClassSettDto();// 每个payType数据相加的总计
//        settDto.setWxAmt(BigDecimal.ZERO);
//        settDto.setPosAmt(BigDecimal.ZERO);
//        settDto.setTotalWxServiceCharge(BigDecimal.ZERO);
//        settDto.setTotalPosServiceCharge(BigDecimal.ZERO);
//        settDto.setTotalAmt(BigDecimal.ZERO);
//        settDto.setTotalRechargeAmt(BigDecimal.ZERO);
//        settDto.setTotalGiveAmt(BigDecimal.ZERO);
//        settDto.setTotalWithdrawalAmount(BigDecimal.ZERO);
//        settDto.setTotalRefundAmt(BigDecimal.ZERO);
//        settDto.setTotalServiceCharge(BigDecimal.ZERO);
//        ArrayList<ClassSettlementCard> settList = new ArrayList<>(); // 包含所有payType数据的列表
//        // 遍历所有的payType,添加map中没有的类型，并进行总计
//        for (CardRecordType value : CardRecordType.values()) {
//            ClassSettlementCard settlement = map.get(value);
//            if (settlement == null) {
//                settlement = new ClassSettlementCard();
//                settlement.setPayType(value.getKey());
//                settlement.setAmt(BigDecimal.ZERO);
//                settlement.setOrderCount(0L);
//                settlement.setServiceCharge(BigDecimal.ZERO);
//                settlement.setGiveAmt(BigDecimal.ZERO);
//                settlement.setWithdrawalAmount(BigDecimal.ZERO);
//            }
//            settList.add(settlement);
//            settDto.setTotalOrderCount((int) (settDto.getTotalOrderCount()+ settlement.getOrderCount()));
//            switch (value){
////                case MANUAL_ADD:
////                    settDto.setTotalAmt(settDto.getTotalAmt().add(settlement.getAmt()));
////                    break;
////                case MANUAL_SUB:
////                    settlement.setAmt(settlement.getAmt().negate());
////                    settDto.setTotalAmt(settDto.getTotalAmt().add(settlement.getAmt()));
////                    break;
//                case WX_RECHARGE:
//                    settDto.setTotalAmt(settDto.getTotalAmt().add(settlement.getAmt()));
//                    settDto.setWxAmt(settDto.getWxAmt().add(settlement.getAmt()));
//                    settDto.setTotalWxServiceCharge(settDto.getTotalWxServiceCharge().add(settlement.getServiceCharge()));
//                    settDto.setAllAmt(settDto.getTotalAmt().add(settlement.getAmt()));
//                    settDto.setTotalGiveAmt(settDto.getTotalGiveAmt().add(settlement.getGiveAmt()));
//                    settlement.setWithdrawalAmount(settlement.getAmt().subtract(settlement.getServiceCharge())); // 充值提现=实收-渠道费
//                    settDto.setTotalWithdrawalAmount(settDto.getTotalWithdrawalAmount().add(settlement.getWithdrawalAmount()));
//                    settDto.setTotalRechargeAmt(settDto.getTotalRechargeAmt().add(settlement.getAmt()));
//                    settDto.setTotalServiceCharge(settDto.getTotalServiceCharge().add(settlement.getServiceCharge()));
//                    settDto.setAmt(settlement.getAmt());
//                    settDto.setOrderCount(settlement.getOrderCount());
//                    break;
//                case MANUAL_ADD:
//                    settDto.setAllAmt(settDto.getTotalAmt().add(settlement.getAmt()));
//
//                    break;
//                case MANUAL_SUB:
//                    settDto.setAllAmt(settDto.getTotalAmt().subtract(settlement.getAmt()));
//                    break;
////                case CONSUME:
////                    settlement.setAmt(settlement.getAmt().negate());
////                    settDto.setTotalAmt(settDto.getTotalAmt().add(settlement.getAmt()));
////                    break;
//                case POS_RECHARGE:
//                    settDto.setPosAmt(settDto.getPosAmt().add(settlement.getAmt()));
//                    settDto.setTotalPosServiceCharge(settDto.getTotalPosServiceCharge().add(settlement.getServiceCharge()));
//                    settDto.setTotalAmt(settDto.getTotalAmt().add(settlement.getAmt()));
//                    settDto.setAllAmt(settDto.getTotalAmt().add(settlement.getAmt()));
//                    settDto.setTotalGiveAmt(settDto.getTotalGiveAmt().add(settlement.getGiveAmt()));
//                    settlement.setWithdrawalAmount(settlement.getAmt().subtract(settlement.getServiceCharge())); // 充值提现=实收-渠道费
//                    settDto.setTotalWithdrawalAmount(settDto.getTotalWithdrawalAmount().add(settlement.getWithdrawalAmount()));
//                    settDto.setTotalRechargeAmt(settDto.getTotalRechargeAmt().add(settlement.getAmt()));
//                    settDto.setTotalServiceCharge(settDto.getTotalServiceCharge().add(settlement.getServiceCharge()));
//                    settDto.setAmt(settlement.getAmt());
//                    settDto.setOrderCount(settlement.getOrderCount());
//                    break;
//                case POS_REFUND:
//                    settDto.setTotalAmt(settDto.getTotalAmt().subtract(settlement.getAmt()));
//                    settDto.setPosAmt(settDto.getPosAmt().subtract(settlement.getAmt()));
//                    settDto.setTotalPosServiceCharge(MathUtil.subtract(settDto.getTotalPosServiceCharge(),settlement.getServiceCharge()));
//                    settDto.setAllAmt(settDto.getTotalAmt().subtract(settlement.getAmt()));
//                    settDto.setTotalRefundAmt(settDto.getTotalRefundAmt().add(settlement.getAmt()));
//                    settDto.setTotalGiveAmt(MathUtil.subtract(settDto.getTotalGiveAmt(),settlement.getGiveAmt()));
//                    settlement.setWithdrawalAmount(settlement.getServiceCharge().subtract(settlement.getAmt())); // 退款提现=-(实收-渠道费)，总提现要加上这个值
//                    settDto.setTotalWithdrawalAmount(settDto.getTotalWithdrawalAmount().add(settlement.getWithdrawalAmount()));
//                    settDto.setTotalServiceCharge(MathUtil.subtract(settDto.getTotalServiceCharge(),settlement.getServiceCharge()));
//                    break;
//                case REFUND:
//                    settDto.setTotalAmt(settDto.getTotalAmt().subtract(settlement.getAmt()));
//                    settDto.setWxAmt(settDto.getWxAmt().subtract(settlement.getAmt()));
//                    settDto.setTotalWxServiceCharge(MathUtil.subtract(settDto.getTotalWxServiceCharge(),settlement.getServiceCharge()));
//                    settDto.setAllAmt(settDto.getTotalAmt().subtract(settlement.getAmt()));
//                    settDto.setTotalRefundAmt(settDto.getTotalRefundAmt().add(settlement.getAmt()));
//                    settDto.setTotalGiveAmt(MathUtil.subtract(settDto.getTotalGiveAmt(),settlement.getGiveAmt()));
//                    settlement.setWithdrawalAmount(settlement.getServiceCharge().subtract(settlement.getAmt())); // 退款提现=-(实收-渠道费)，总提现要加上这个值
//                    settDto.setTotalWithdrawalAmount(settDto.getTotalWithdrawalAmount().add(settlement.getWithdrawalAmount()));
//                    settDto.setTotalServiceCharge(MathUtil.subtract(settDto.getTotalServiceCharge(),settlement.getServiceCharge()));
//                    //settlement.setAmt(settlement.getAmt().negate());
//                    break;
//            }
//        }
////        ClassSettlementCard countDto = new ClassSettlementCard();
////        countDto.setPayType("zj");
////        countDto.setAmt(settDto.getTotalAmt());
////        countDto.setOrderCount((long)settDto.getOrderCount());
////        countDto.setWithdrawalAmount(settDto.getTotalWithdrawalAmount());
////        settList.add(countDto);
//        settDto.setSettlementCardList(settList);
//        return settDto;
//    }
//
//
//    /**
//     * 班结分组关系到充值
//     *
//     * @param
//     * @return 结果
//     */
//    @Override
//    public List<ClassSettlementCard> queryGroupByRecharge(List<Map<String, Object>> queryGroupByPayType,CardClassSettDto settDto) {
//        List<ClassSettlementCard> queryGroupByRecharge = new ArrayList<ClassSettlementCard>();
//        ClassSettlementCard dkqClassSettlementCard = new ClassSettlementCard();
//        dkqClassSettlementCard.setPayType("dkq");
//        dkqClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
//        dkqClassSettlementCard.setAmt(BigDecimal.ZERO);
//        dkqClassSettlementCard.setOrderCount(0L);
//        Map<String, Object> dzkCus = null;
//        if (queryGroupByPayType != null && !queryGroupByPayType.isEmpty()) {
//            for (Map<String, Object> obj : queryGroupByPayType) {
//                if (obj.containsKey("pay_type") && obj.get("pay_type").equals("dkq")) {
//                    dkqClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
//                    double amtDouble = (obj.get("amt") != null) ? (double) obj.get("amt") : 0.0;
//                    BigDecimal amt = BigDecimal.valueOf(amtDouble);
//                    dkqClassSettlementCard.setAmt(amt); // 强制类型转换
//                    Long order_count = (obj.get("order_count") != null) ? ((BigDecimal) obj.get("order_count")).longValue() : 0L;
//                    dkqClassSettlementCard.setOrderCount(order_count); // 强制类型转换
//                }
//                if (obj.containsKey("pay_type") && obj.get("pay_type").equals("dzk")) {
//                    dzkCus = obj;
//                }
//            }
//        }
//        queryGroupByRecharge.add(dkqClassSettlementCard);
//        List<ClassSettlementCard> classSettlementDZK = settDto.getSettlementCardList();
//        for(ClassSettlementCard classSettlementDZKItem:classSettlementDZK){
//            if(classSettlementDZKItem.getPayType().equals("msub")){
//                ClassSettlementCard newClassSettlementCard = new ClassSettlementCard();
//                newClassSettlementCard.setPayType("msub");
//                newClassSettlementCard.setGiveAmt(BigDecimal.ZERO);
//                newClassSettlementCard.setAmt(MathUtil.add(classSettlementDZKItem.getAmt(),classSettlementDZKItem.getGiveAmt()));
//                newClassSettlementCard.setOrderCount(classSettlementDZKItem.getOrderCount());
//                queryGroupByRecharge.add(newClassSettlementCard);
//            }
////            else if(classSettlementDZKItem.getPayType().equals("")){
////                ClassSettlementCard newClassSettlementCard = new ClassSettlementCard();
////                newClassSettlementCard.setPayType("");
////                newClassSettlementCard.setGiveAmt(classSettlementDZKItem.getGiveAmt());
////                newClassSettlementCard.setAmt(classSettlementDZKItem.getAmt());
////                newClassSettlementCard.setOrderCount(classSettlementDZKItem.getOrderCount());
////                queryGroupByRecharge.add(newClassSettlementCard);
////            }
//        }
//        if (dzkCus != null) {
//            ClassSettlementCard newClassSettlementCard = new ClassSettlementCard();
//            newClassSettlementCard.setPayType("");
//            double discountAmtDouble = (dzkCus.get("discount_amt") != null) ? (double) dzkCus.get("discount_amt") : 0d;
//            double discountCouponAmtDouble = (dzkCus.get("discount_coupon_amt") != null) ? (double) dzkCus.get("discount_coupon_amt") : 0d;
//            newClassSettlementCard.setGiveAmt(BigDecimal.valueOf(discountAmtDouble).add(BigDecimal.valueOf(discountCouponAmtDouble)));
//            newClassSettlementCard.setAmt((dzkCus.get("amt") != null) ? BigDecimal.valueOf((double) dzkCus.get("amt")) : BigDecimal.ZERO);
//            newClassSettlementCard.setOrderCount((dzkCus.get("order_count") != null) ? ((BigDecimal) dzkCus.get("order_count")).longValue() : 0L);
//            queryGroupByRecharge.add(newClassSettlementCard);
//        }
//        return queryGroupByRecharge;
//    }
//    /**
//     * 修改班结
//     *
//     * @param classSettlement 班结
//     * @return 结果
//     */
//    @Override
//    public int updateClassSettlement(ClassSettlement classSettlement) {
//        return classSettlementMapper.updateClassSettlement(classSettlement);
//    }
//
//    /**
//     * 批量删除班结
//     *
//     * @param classNo 需要删除的班结ID
//     * @return 结果
//     */
//    @Override
//    public int deleteClassSettlementByClassNos(String[] classNo) {
//        classSettlementCardMapper.deleteClassSettlementByClassNos(classNo);
//        classSettlementCardMapper.deleteOilByClassNos(classNo);
//        classSettlementCardMapper.deleteOilOmeterByClassNos(classNo);
//        return classSettlementMapper.deleteClassSettlementByClassNos(classNo);
//    }
//
//    /**
//     * 删除班结信息
//     *
//     * @param classSettlementId 班结ID
//     * @return 结果
//     */
//    @Override
//    public int deleteClassSettlementById(Long classSettlementId) {
//        return classSettlementMapper.deleteClassSettlementById(classSettlementId);
//    }
//
//
//    // 根据station_id修改白班时间
//    @Override
//    public int updateDayShiftTimeById(Time dayShiftStartTime, Time dayShiftEndTime, Time nightShiftStartTime, Time nightShiftEndTime, StationClassTimeDto timeDto){
//        LoginUser currentUser = SecurityUtils.getLoginUser();
//        SysUser user = currentUser.getUser();
//
//        if (user.getUserLevel() == null) {
//            return 0;
//        } else if (user.getUserLevel() != null && user.getUserLevel().equals("1")) {
//            int a = 0;
//            Map<String, Object> params = new HashMap<>();
//            params.put("enterpriseId", user.getEnterpriseId().intValue());
//            params.put("dayShiftStartTime", dayShiftStartTime);
//            params.put("dayShiftEndTime", dayShiftEndTime);
//            params.put("nightShiftStartTime", nightShiftStartTime);
//            params.put("nightShiftEndTime", nightShiftEndTime);
//            params.put("dayShiftUserIds", timeDto.getDayShiftUserIds());
//            params.put("nightShiftUserIds", timeDto.getNightShiftUserIds());
//            a= a+classSettlementMapper.updateDayShiftTimeByEnterpriseId(params);
//            Station station = new Station();
//            station.setEnterpriseId(user.getEnterpriseId());
//            List<Station> stations = stationMapper.selectStationList(station);
//            for (Station ss : stations) {
//                params.put("stationId", ss.getStationId().intValue());
//                a= a+ classSettlementMapper.updateDayShiftTimeByStationId(params);
//            }
//            return a;
//
//        } else if (user.getUserLevel().equals("2")) {
//            Map<String, Object> params = new HashMap<>();
//            params.put("stationId", user.getStationId().intValue());
//            params.put("dayShiftStartTime", dayShiftStartTime);
//            params.put("dayShiftEndTime", dayShiftEndTime);
//            params.put("nightShiftStartTime", nightShiftStartTime);
//            params.put("nightShiftEndTime", nightShiftEndTime);
//            params.put("dayShiftUserIds", timeDto.getDayShiftUserIds());
//            params.put("nightShiftUserIds", timeDto.getNightShiftUserIds());
//            return classSettlementMapper.updateDayShiftTimeByStationId(params);
//        }else{
//            return 0;
//        }
//    };
//
//
//    @Override
//    public StationClassTimeVo selectDayShiftTimeById(){
//        LoginUser currentUser = SecurityUtils.getLoginUser();
//        SysUser user = currentUser.getUser();
//
//        if (user.getUserLevel() == null) {
//            return null;
//        } else if (user.getUserLevel() != null && user.getUserLevel().equals("1")) {
//            return classSettlementMapper.selectDayShiftTimeByEnterpriseId(user.getEnterpriseId().intValue());
//        } else if (user.getUserLevel().equals("2")) {
//            return classSettlementMapper.selectDayShiftTimeByStationId(user.getStationId().intValue());
//        } else {
//            return null;
//        }
//    }
//
//
//
//    /**
//     * 查询未班结信息
//     *
//     * @param params
//     * @return 结果
//     */
//    @Override
//    public List<ClassSettlement> querySummaryByClassNoForOrder(Map<String, Object> params) {
//        return classSettlementMapper.querySummaryByClassNoForOrder(params);
//    }
//
//    @Override
//    public List<ClassSettlement> employeeQuerySummaryByClassNoForOrder(Map<String, Object> params) {
//        return classSettlementMapper.employeeQuerySummaryByClassNoForOrder(params);
//    }
//
//    @Override
//    public List<ClassSettlement> queryUntreatedData(Map<String, Object> params) {
//        return classSettlementMapper.queryUntreatedData(params);
//    }
//
//    @Override
//    public void selectChange4User4POSListForOrder(Map<String, Object> params) {
//        List<changeClassSettlement4User> changeClassSettlement4User=classSettlementMapper.selectChange4User4POSListForOrder(params);
//        for (changeClassSettlement4User changeClassSettlement :changeClassSettlement4User){
//            changeClassSettlement.setPresentAmount(BigDecimal.ZERO);
//            changeClassSettlement.setTotalDiscountAmt(BigDecimal.ZERO);
//            changeClassSettlement.setReceivableAmt(changeClassSettlement.getAmt());
//            changeClassSettlement.setClassNo( params.get("no").toString());
//            classSettlementMapper.addChange4User4POSListForOrder(changeClassSettlement);
//        }
//
//    }
//
//    @Override
//    public void insertAboutOil(Map<String, Object> params,String no,String classEndTime,Long stationId) {
//        List<Map<String, Object>> queryGroupByOilGun = this.queryGroupByOilGunForOrder(params);
//        Iterator<Map<String, Object>> iterator2 = queryGroupByOilGun.iterator();
//        while (iterator2.hasNext()) {
//            Map<String, Object> map = iterator2.next();
//            if (!map.containsKey("oil_gun")) {
//                iterator2.remove();
//            }
//        }
//        List<OilEngineDto> newQueryGroupByOilGun = classSettlementMapper.classSettlementOilEngineSum(params);
//        List<String> oilGunListA = new ArrayList<>();
//        List<String> oilGunListB = new ArrayList<>();
//        if (queryGroupByOilGun.size() > 0 && newQueryGroupByOilGun.size() > 0) {
//            for (Map<String, Object> map : queryGroupByOilGun) {
//                String oilGun = map.get("oil_gun").toString();
//                map.put("class_no",no);
//                map.put("class_end_time",classEndTime);
//                map.put("station_id",stationId);
//                oilGunListA.add(oilGun); // 存储a列表的油枪数据
//                oilGunListB.clear();
//                for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                    oilGunListB.add(oilEngineDto.getOilGun());
//                    if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//                        map.put("oil_price", oilEngineDto.getOilPrice());
//                        map.put("class_no",no);
//                        map.put("class_end_time",classEndTime);
//                        map.put("station_id",stationId);
//                        map.put("order_liters", oilEngineDto.getOrderLiters());
//                        map.put("oil_name", oilEngineDto.getOilName());
//                        map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                        map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                    }
//                }
//            }
//            List<String> difference = new ArrayList<>();
//            for (String value : oilGunListB) {
//                if (!oilGunListA.contains(value)) {
//                    difference.add(value);
//                }
//            }
//            for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                for (String oilGun : difference) {
//
//                    if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//
//                        Map<String, Object> map = new HashMap<>();
//                        map.put("class_no",no);
//                        map.put("class_end_time",classEndTime);
//                        map.put("station_id",stationId);
//                        map.put("oil_gun", oilEngineDto.getOilGun());
//                        map.put("oil_price", oilEngineDto.getOilPrice());
//                        map.put("order_liters", oilEngineDto.getOrderLiters());
//                        map.put("oil_name", oilEngineDto.getOilName());
//                        map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                        map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                        queryGroupByOilGun.add(map);
//                    }
//                }
//            }
//
//        } else if (queryGroupByOilGun.size() == 0 && newQueryGroupByOilGun.size() > 0) {
//            for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                if (oilEngineDto != null && oilEngineDto.getOilGun() != null) {
//                    Map<String, Object> map = new HashMap<>();
//                    map.put("class_no",no);
//                    map.put("class_end_time",classEndTime);
//                    map.put("station_id",stationId);
//                    map.put("oil_gun", oilEngineDto.getOilGun());
//                    map.put("oil_price", oilEngineDto.getOilPrice());
//                    map.put("order_liters", oilEngineDto.getOrderLiters());
//                    map.put("oil_name", oilEngineDto.getOilName());
//                    map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                    map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                    queryGroupByOilGun.add(map);
//
//                }
//            }
//        }
//        List<OilOmeter> oilOmeters =  classSettlementMapper.selectByStationId(stationId);
//        for (OilOmeter oilOmeter:oilOmeters){
//            oilOmeter.setClassEndTime(classEndTime);
//            oilOmeter.setClassNo(no);
//            classSettlementMapper.insertSelective(oilOmeter);
//        }
//        if(queryGroupByOilGun.size()!=0){
//            classSettlementMapper.insertAboutOilEngine(queryGroupByOilGun);
//        }
//    }
//
//    @Override
//    public List<changeClassSettlement4User> selectForRecharge(Map<String,Object> params) {
//        List<changeClassSettlement4User> changeClassSettlement4User =  classSettlementMapper.select4UserListForOrder(params);
//        changeClassSettlement4User allChangeForUser = new changeClassSettlement4User();
//        allChangeForUser.setOilPersonnelName("合计");
//        allChangeForUser.setOrderCount(0);
//        allChangeForUser.setAmt(BigDecimal.ZERO);
//        for(changeClassSettlement4User change4User:changeClassSettlement4User){
//            allChangeForUser.setOrderCount(allChangeForUser.getOrderCount()+change4User.getOrderCount());
//            allChangeForUser.setAmt(allChangeForUser.getAmt().add(change4User.getAmt()));
//        }
//        changeClassSettlement4User.add(allChangeForUser);
//        return changeClassSettlement4User;
//    }
//
//    @Override
//    public List<ClassSettlement> employeeQueryUntreatedData(Map<String, Object> params) {
//        return classSettlementMapper.employeeQueryUntreatedData(params);
//    }
//
//    @Override
//    public ClassSettlementCard queryPhysicalCard(Map<String, Object> params) {
//        return classSettlementMapper.queryPhysicalCard(params);
//    }
//
//    @Override
//    public ClassSettlementCard queryPhysicalCardRef(Map<String, Object> params) {
//        return classSettlementMapper.queryPhysicalCardRef(params);
//    }
//
//
//    @Override
//    public ClassSettlementCard queryFleetCard(Map<String, Object> params) {
//        return classSettlementMapper.queryFleetCard(params);
//    }
//
//    @Override
//    public ClassSettlementCard querySuperPay(Map<String, Object> params) {
//        ClassSettlementCard superRef =   classSettlementMapper.queryRefundSuperPay(params);
//        ClassSettlementCard superAmt =  classSettlementMapper.querySuperPay(params)!=null?
//                classSettlementMapper.querySuperPay(params):new ClassSettlementCard();
//        BigDecimal superRefAmt = superRef.getAmt()!=null?superRef.getAmt():BigDecimal.ZERO;
//        superAmt.setRefundAmount(superRefAmt);
//        return superAmt;
//    }
//
//    @Override
//    public BigDecimal forKillCouponAmt(Map<String, Object> params) {
//        BigDecimal forKillCouponAmt = BigDecimal.ZERO;
//        ClassSettlementCard forKillCoupon = classSettlementMapper.forKillCouponAmt(params);
//        forKillCouponAmt = forKillCoupon.getAmt()!=null?forKillCoupon.getAmt():BigDecimal.ZERO;
//        return forKillCouponAmt;
//    }
//
//    @Override
//    public BigDecimal forSaleActivityAmt(Map<String, Object> params) {
//        ClassSettlementCard forSaleActivity = classSettlementMapper.forSaleActivityAmt(params);
//        BigDecimal forSaleActivityAmt   = forSaleActivity.getWithdrawalAmount()!=null?forSaleActivity.getWithdrawalAmount():BigDecimal.ZERO;
//        return forSaleActivityAmt;
//    }
//
//    @Override
//    public ClassSettlementCard forSaleActivity(Map<String, Object> params) {
//        ClassSettlementCard forSaleActivity = classSettlementMapper.forSaleActivityAmt(params) !=null?classSettlementMapper.forSaleActivityAmt(params):new ClassSettlementCard();
//
//        return forSaleActivity;
//    }
//
//    @Override
//    public BigDecimal forSaleActivityCom(Map<String, Object> params) {
//        ClassSettlementCard forSaleActivity = classSettlementMapper.forSaleActivityAmt(params);
//        BigDecimal forSaleActivityCom   = forSaleActivity.getServiceCharge()!=null?forSaleActivity.getServiceCharge():BigDecimal.ZERO;
//        return forSaleActivityCom;
//    }
//
//    @Override
//    public BigDecimal refSaleActivityAmt(Map<String, Object> params) {
//        ClassSettlementCard forSaleActivity =   classSettlementMapper.refSaleActivityAmt(params);
//        BigDecimal refSaleActivityAmt   = forSaleActivity.getAmt()!=null?forSaleActivity.getAmt():BigDecimal.ZERO;
//        return refSaleActivityAmt;
//    }
//
//
//
//    @Override
//    public BigDecimal employeeForKillCouponAmt(Map<String, Object> params) {
//        BigDecimal forKillCouponAmt = BigDecimal.ZERO;
//        ClassSettlementCard forKillCoupon = classSettlementMapper.employeeForKillCouponAmt(params);
//        forKillCouponAmt = forKillCoupon.getAmt();
//        return forKillCouponAmt;
//    }
//
//    @Override
//    public BigDecimal forActualRechargeReceivedAmt(CardClassSettDto settDto, Map<String, Object> params) {
//        BigDecimal actualRechargeReceivedAmt =  settDto.getAllAmt();
//        actualRechargeReceivedAmt = (actualRechargeReceivedAmt != null) ? actualRechargeReceivedAmt : BigDecimal.ZERO;
//        ClassSettlementCard physicalCard = classSettlementMapper.queryPhysicalCard(params);
//        ClassSettlementCard fleetCard = classSettlementMapper.queryFleetCard(params);
//        ClassSettlementCard superPay = classSettlementMapper.querySuperPay(params);
//        if (actualRechargeReceivedAmt != null) {
//            BigDecimal physicalCardAmt = physicalCard.getAmt() != null ? physicalCard.getAmt() : BigDecimal.ZERO;
//            BigDecimal fleetCardAmt = fleetCard.getAmt() != null ? fleetCard.getAmt() : BigDecimal.ZERO;
//            BigDecimal superPayAmt = superPay.getAmt() != null ? superPay.getAmt() : BigDecimal.ZERO;
//            actualRechargeReceivedAmt = actualRechargeReceivedAmt.add(physicalCardAmt).add(fleetCardAmt).add(superPayAmt);
//
//        }
//        return actualRechargeReceivedAmt;
//    }
//
//    @Override
//    public BigDecimal homeRechargeReceivedAmt( Map<String, Object> params) {
//        BigDecimal  actualRechargeReceivedAmt = BigDecimal.ZERO;
//        ClassSettlementCard physicalCard = classSettlementMapper.queryPhysicalCard(params);
//        ClassSettlementCard refPhysicalCard = classSettlementMapper.queryPhysicalCardRef(params);
//        ClassSettlementCard fleetCard = classSettlementMapper.queryFleetCard(params);
//        ClassSettlementCard superPay = classSettlementMapper.querySuperPay(params);
//        ClassSettlementCard dzkCard = classSettlementMapper.queryDzkCard(params);
//        BigDecimal refPhysicalCardAmt = refPhysicalCard.getAmt() != null ? refPhysicalCard.getAmt() : BigDecimal.ZERO;
//            BigDecimal physicalCardAmt = physicalCard.getAmt() != null ? physicalCard.getAmt() : BigDecimal.ZERO;
//            BigDecimal fleetCardAmt = fleetCard.getAmt() != null ? fleetCard.getAmt() : BigDecimal.ZERO;
//        BigDecimal dzkAmt = BigDecimal.ZERO;
//        BigDecimal refDzkAmt =  BigDecimal.ZERO;
//          if(dzkCard!=null){
//               dzkAmt = dzkCard.getAmt() != null ? dzkCard.getAmt() : BigDecimal.ZERO;
//               refDzkAmt = dzkCard.getRefundAmount() != null ? dzkCard.getRefundAmount() : BigDecimal.ZERO;
//          }
//        BigDecimal superPayAmt = superPay.getAmt() != null ? superPay.getAmt() : BigDecimal.ZERO;
//            actualRechargeReceivedAmt = actualRechargeReceivedAmt.add(physicalCardAmt)
//                    .add(fleetCardAmt).add(superPayAmt)
//                    .add(dzkAmt).subtract(refDzkAmt)
//                    .subtract(refPhysicalCardAmt);
//        return actualRechargeReceivedAmt;
//    }
//
//    @Override
//    public List<ClassSettlementCard> homeRechargeReceivedAmtSeven( Map<String, Object> params) {
//        ZoneId zoneId = ZoneId.of("Asia/Shanghai");
//        LocalDate comparedate1 = LocalDate.now().minusDays(7);
//        LocalDate comparedate2 = LocalDate.now().minusDays(6);
//        LocalDate comparedate3 = LocalDate.now().minusDays(5);
//        LocalDate comparedate4 = LocalDate.now().minusDays(4);
//        LocalDate comparedate5 = LocalDate.now().minusDays(3);
//        LocalDate comparedate6 = LocalDate.now().minusDays(2);
//        LocalDate comparedate7 = LocalDate.now().minusDays(1);
//        List<LocalDate>  createdList = new ArrayList<>();
//        params.put("createdList",createdList);
//        createdList.add(comparedate1);
//        createdList.add(comparedate2);
//        createdList.add(comparedate3);
//        createdList.add(comparedate4);
//        createdList.add(comparedate5);
//        createdList.add(comparedate6);
//        createdList.add(comparedate7);
//
//        BigDecimal paycount1 = BigDecimal.ZERO;
//        BigDecimal paycount2 = BigDecimal.ZERO;
//        BigDecimal paycount3 = BigDecimal.ZERO;
//        BigDecimal paycount4 = BigDecimal.ZERO;
//        BigDecimal paycount5 = BigDecimal.ZERO;
//        BigDecimal paycount6 = BigDecimal.ZERO;
//        BigDecimal paycount7 = BigDecimal.ZERO;
//
//        BigDecimal  actualRechargeReceivedAmt = BigDecimal.ZERO;
//        List<ClassSettlementCard> dzkCards = classSettlementMapper.homeDzkCard(params);
//        List<ClassSettlementCard> physicalCards= classSettlementMapper.homePhysical(params);
//        List<ClassSettlementCard> refPhysicalCards = classSettlementMapper.homePhysicalRef(params);
//        List<ClassSettlementCard> fleetCards = classSettlementMapper.homeFleet(params);
//        List<ClassSettlementCard> superPays = classSettlementMapper.homeSuperPay(params);
//        for (ClassSettlementCard dzkCard : dzkCards) {
//            LocalDate localDate = dzkCard.getCreateTime().toInstant().atZone(zoneId).toLocalDateTime().toLocalDate();
//            BigDecimal amt2 =   dzkCard.getAmt() != null ? dzkCard.getAmt() : BigDecimal.ZERO;
//            BigDecimal amt3 =  dzkCard.getRefundAmount() != null ? dzkCard.getRefundAmount() : BigDecimal.ZERO;
//            if (localDate.equals(comparedate1)) {
//                paycount1 = paycount1.add(amt2).subtract(amt3);
//            }
//            if (localDate.equals(comparedate2)) {
//                paycount2 = paycount2.add(amt2).subtract(amt3);
//            }
//            if (localDate.equals(comparedate3)) {
//                paycount3 = paycount3.add(amt2).subtract(amt3);
//            }
//            if (localDate.equals(comparedate4)) {
//                paycount4 = paycount4.add(amt2).subtract(amt3);
//            }
//            if (localDate.equals(comparedate5)) {
//                paycount5 = paycount5.add(amt2).subtract(amt3);
//            }
//            if (localDate.equals(comparedate6)) {
//                paycount6 = paycount6.add(amt2).subtract(amt3);
//            }
//            if (localDate.equals(comparedate7)) {
//                paycount7 = paycount7.add(amt2).subtract(amt3);
//            }
//        }
//        for (ClassSettlementCard physicalCard : physicalCards) {
//            LocalDate localDate = physicalCard.getCreateTime().toInstant().atZone(zoneId).toLocalDateTime().toLocalDate();
//            BigDecimal amt2 =  physicalCard.getAmt() != null ? physicalCard.getAmt() : BigDecimal.ZERO;
//            if (localDate.equals(comparedate1)) {
//                paycount1 = paycount1.add(amt2);
//            }
//            if (localDate.equals(comparedate2)) {
//                paycount2 = paycount2.add(amt2);
//            }
//            if (localDate.equals(comparedate3)) {
//                paycount3 = paycount3.add(amt2);
//            }
//            if (localDate.equals(comparedate4)) {
//                paycount4 = paycount4.add(amt2);
//            }
//            if (localDate.equals(comparedate5)) {
//                paycount5 = paycount5.add(amt2);
//            }
//            if (localDate.equals(comparedate6)) {
//                paycount6 = paycount6.add(amt2);
//            }
//            if (localDate.equals(comparedate7)) {
//                paycount7 = paycount7.add(amt2);
//            }
//        }
//        for (ClassSettlementCard refPhysicalCard : refPhysicalCards) {
//            LocalDate localDate = refPhysicalCard.getCreateTime().toInstant().atZone(zoneId).toLocalDateTime().toLocalDate();
//            BigDecimal amt2 = refPhysicalCard.getAmt() != null ? refPhysicalCard.getAmt() : BigDecimal.ZERO;
//            if (localDate.equals(comparedate1)) {
//                paycount1 = paycount1.subtract(amt2);
//            }
//            if (localDate.equals(comparedate2)) {
//                paycount2 = paycount2.subtract(amt2);
//            }
//            if (localDate.equals(comparedate3)) {
//                paycount3 = paycount3.subtract(amt2);
//            }
//            if (localDate.equals(comparedate4)) {
//                paycount4 = paycount4.subtract(amt2);
//            }
//            if (localDate.equals(comparedate5)) {
//                paycount5 = paycount5.subtract(amt2);
//            }
//            if (localDate.equals(comparedate6)) {
//                paycount6 = paycount6.subtract(amt2);
//            }
//            if (localDate.equals(comparedate7)) {
//                paycount7 = paycount7.subtract(amt2);
//            }
//        }
//        for (ClassSettlementCard fleetCard : fleetCards) {
//            LocalDate localDate = fleetCard.getCreateTime().toInstant().atZone(zoneId).toLocalDateTime().toLocalDate();
//            BigDecimal amt2 =  fleetCard.getAmt() != null ? fleetCard.getAmt() : BigDecimal.ZERO;
//            if (localDate.equals(comparedate1)) {
//                paycount1 = paycount1.add(amt2);
//            }
//            if (localDate.equals(comparedate2)) {
//                paycount2 = paycount2.add(amt2);
//            }
//            if (localDate.equals(comparedate3)) {
//                paycount3 = paycount3.add(amt2);
//            }
//            if (localDate.equals(comparedate4)) {
//                paycount4 = paycount4.add(amt2);
//            }
//            if (localDate.equals(comparedate5)) {
//                paycount5 = paycount5.add(amt2);
//            }
//            if (localDate.equals(comparedate6)) {
//                paycount6 = paycount6.add(amt2);
//            }
//            if (localDate.equals(comparedate7)) {
//                paycount7 = paycount7.add(amt2);
//            }
//        }
//        for (ClassSettlementCard superPay : superPays) {
//            LocalDate localDate = superPay.getCreateTime().toInstant().atZone(zoneId).toLocalDateTime().toLocalDate();
//            BigDecimal amt2 =  superPay.getAmt() != null ? superPay.getAmt() : BigDecimal.ZERO;
//            if (localDate.equals(comparedate1)) {
//                paycount1 = paycount1.add(amt2);
//            }
//            if (localDate.equals(comparedate2)) {
//                paycount2 = paycount2.add(amt2);
//            }
//            if (localDate.equals(comparedate3)) {
//                paycount3 = paycount3.add(amt2);
//            }
//            if (localDate.equals(comparedate4)) {
//                paycount4 = paycount4.add(amt2);
//            }
//            if (localDate.equals(comparedate5)) {
//                paycount5 = paycount5.add(amt2);
//            }
//            if (localDate.equals(comparedate6)) {
//                paycount6 = paycount6.add(amt2);
//            }
//            if (localDate.equals(comparedate7)) {
//                paycount7 = paycount7.add(amt2);
//            }
//        }
//        List<ClassSettlementCard> allChange = new ArrayList<>();
//        ClassSettlementCard allChangeItem= new ClassSettlementCard();
//        ClassSettlementCard allChangeItem1 = new ClassSettlementCard();
//        allChangeItem1.setAmt(paycount1);
//        allChangeItem1.setCreateTime(Date.from(comparedate1.atStartOfDay(ZoneId.systemDefault()).toInstant()));
//        allChange.add(allChangeItem1);
//        ClassSettlementCard allChangeItem2 = new ClassSettlementCard();
//        allChangeItem2.setAmt(paycount2);
//        allChangeItem2.setCreateTime(Date.from(comparedate2.atStartOfDay(ZoneId.systemDefault()).toInstant()));
//        allChange.add(allChangeItem2);
//
//        ClassSettlementCard allChangeItem3 = new ClassSettlementCard();
//        allChangeItem3.setAmt(paycount3);
//        allChangeItem3.setCreateTime(Date.from(comparedate3.atStartOfDay(ZoneId.systemDefault()).toInstant()));
//        allChange.add(allChangeItem3);
//
//        ClassSettlementCard allChangeItem4 = new ClassSettlementCard();
//        allChangeItem4.setAmt(paycount4);
//        allChangeItem4.setCreateTime(Date.from(comparedate4.atStartOfDay(ZoneId.systemDefault()).toInstant()));
//        allChange.add(allChangeItem4);
//
//        ClassSettlementCard allChangeItem5 = new ClassSettlementCard();
//        allChangeItem5.setAmt(paycount5);
//        allChangeItem5.setCreateTime(Date.from(comparedate5.atStartOfDay(ZoneId.systemDefault()).toInstant()));
//        allChange.add(allChangeItem5);
//
//        ClassSettlementCard allChangeItem6 = new ClassSettlementCard();
//        allChangeItem6.setAmt(paycount6);
//        allChangeItem6.setCreateTime(Date.from(comparedate6.atStartOfDay(ZoneId.systemDefault()).toInstant()));
//        allChange.add(allChangeItem6);
//
//        ClassSettlementCard allChangeItem7 = new ClassSettlementCard();
//        allChangeItem7.setAmt(paycount7);
//        allChangeItem7.setCreateTime(Date.from(comparedate7.atStartOfDay(ZoneId.systemDefault()).toInstant()));
//        allChange.add(allChangeItem7);
//
//
//        return allChange;
//    }
//
//
//
//    @Override
//    public Map<String, Object> queryLastEndTime(Map<String, Object> params) {
//        return classSettlementMapper.queryLastEndTime(params);
//    }
//
//    @Override
//    public Map<String, Object> queryStartAndEnd(Map<String, Object> params) {
//        return classSettlementMapper.queryStartAndEnd(params);
//    }
//
//    @Override
//    public List<ClassSettlement> querySummaryByClassNo(Map<String, Object> params) {
//        return classSettlementMapper.querySummaryByClassNo(params);
//
//    }
//
//    @Override
//    public List<ClassSettlement> querySummaryByClassNoAllData(Map<String, Object> params, CardClassSettDto settDto) {
//        List<ClassSettlement> summaryByClassNo = classSettlementMapper.querySummaryByClassNo(params);
////记录一下，总退款在确认班结就处理了
//        BigDecimal actualRechargeReceivedAmt = settDto.getTotalRechargeAmt();
//
//        BigDecimal totalRechargeWithdrawalAmount = settDto.getTotalWithdrawalAmount();
//        BigDecimal totalRechargeRefundAmt = settDto.getTotalRefundAmt();
//
////        //        消费合计退款
////        summaryMap.put("consumptionRefundAmt", consumptionRefundAmt);
//////        优惠金额
////        summaryMap.put("totalDiscountAmt", totalDiscountAmt);
//////        充值合计提现
////        summaryMap.put("totalRechargeWithdrawalAmount", totalRechargeWithdrawalAmount);
//////        充值合计退款
////        summaryMap.put("totalRechargeRefundAmt", totalRechargeRefundAmt);
//////        到账总金额
////        summaryMap.put("allAmt", allAmt);
//
//        BigDecimal allAmt = BigDecimal.ZERO;//到账总金额
//        BigDecimal consumptionRefundAmt = BigDecimal.ZERO;//消费合计退款
//        if (summaryByClassNo != null && !summaryByClassNo.isEmpty()) {
//            ClassSettlement firstItem = summaryByClassNo.get(0);
//            if (firstItem != null) {
//                BigDecimal discountAmt = firstItem.getDiscountAmt()!=null?firstItem.getDiscountAmt(): BigDecimal.ZERO;
//                BigDecimal superPayAmt = firstItem.getSuperPayAmt()!=null?firstItem.getSuperPayAmt(): BigDecimal.ZERO;
//                BigDecimal discountCouponAmt = firstItem.getDiscountCouponAmt()!=null?firstItem.getDiscountCouponAmt(): BigDecimal.ZERO;
//                BigDecimal actualTotalAmt = firstItem.getActualRechargeReceivedAmt()!=null?firstItem.getActualRechargeReceivedAmt(): BigDecimal.ZERO;
//                BigDecimal yhkCommission = firstItem.getYhkCommission()!=null?firstItem.getYhkCommission(): BigDecimal.ZERO;
//                BigDecimal otherCommission = firstItem.getOtherCommission()!=null?firstItem.getOtherCommission(): BigDecimal.ZERO;
//                BigDecimal saleActivityAmt  = firstItem.getSaleActivityAmt();
//                BigDecimal saleAmtCom =firstItem.getSaleActivityCom()!=null?firstItem.getSaleActivityCom():BigDecimal.ZERO;
//                if (discountAmt != null && discountCouponAmt != null) {
//                    BigDecimal totalDiscountAmt = discountAmt.add(discountCouponAmt);
//                    firstItem.setTotalDiscountAmt(totalDiscountAmt);
//
//                }
//                BigDecimal totalWithdrawalAmount = firstItem.getTotalWithdrawalAmount();
//                BigDecimal aggregatedPayment =firstItem.getAggregatedPayment() != null ? firstItem.getAggregatedPayment() : BigDecimal.ZERO;
//                BigDecimal amt = summaryByClassNo.get(0).getAmt();
//                BigDecimal nodzkAmt = summaryByClassNo.get(0).getNodzkAmt();
//                otherCommission=  otherCommission.add(settDto.getTotalServiceCharge()!= null ? settDto.getTotalServiceCharge() : BigDecimal.ZERO).add(saleAmtCom);
//                allAmt = nodzkAmt != null ? nodzkAmt.add(actualTotalAmt != null ? actualTotalAmt : BigDecimal.ZERO) : BigDecimal.ZERO;
//                firstItem.setAllAmt(allAmt);
//                Station station1 = stationMapper.selectStationById(firstItem.getStationId());
//                firstItem.setAggregatedPayment(aggregatedPayment.add(saleActivityAmt != null ? saleActivityAmt : BigDecimal.ZERO));
//                firstItem.setOtherCommission(otherCommission.setScale(2, RoundingMode.HALF_UP));
//                firstItem.setYhkCommission(yhkCommission.setScale(2, RoundingMode.HALF_UP));
//                firstItem.setIsShowCommission(station1.getIsShowCommission());
//                firstItem.setAllCommission(otherCommission.add(yhkCommission).setScale(2, RoundingMode.HALF_UP));
//                firstItem.setTotalRechargeWithdrawalAmount(totalRechargeWithdrawalAmount);
//                ClassSettlementCard physicalCardRef = classSettlementMapper.queryPhysicalCardRef(params);
////                totalRechargeRefundAmt.add(physicalCardRef.getAmt() != null?physicalCardRef.getAmt():BigDecimal.ZERO);
////                firstItem.setTotalRechargeRefundAmt(totalRechargeRefundAmt);
//                firstItem.setTotalWithdrawalAmount(superPayAmt.add(totalWithdrawalAmount != null ? totalWithdrawalAmount : BigDecimal.ZERO).add(saleActivityAmt != null ? saleActivityAmt : BigDecimal.ZERO));
//
//            }
//        } else {
//
//        }
//        return summaryByClassNo;
//    }
//
//    @Override
//    public List<Map<String, Object>> queryGroupByOilForOrder(Map<String, Object> params) {
//        return classSettlementMapper.queryGroupByOilForOrder(params);
//    }
//
//    @Override
//    public List<Map<String, Object>> employeeQueryGroupByOilForOrder(Map<String, Object> params) {
//        return classSettlementMapper.employeeQueryGroupByOilForOrder(params);
//    }
//
//    @Override
//    public List<Map<String, Object>> queryGroupByOil(Map<String, Object> params) {
//        List<Map<String, Object>> queryGroupByOil = classSettlementMapper.queryGroupByOil(params);
//        Iterator<Map<String, Object>> iterator = queryGroupByOil.iterator();
//        while (iterator.hasNext()) {
//            Map<String, Object> map = iterator.next();
//            if (!map.containsKey("oil_name")) {
//                iterator.remove();
//            }
//        }
//        Map<String, Object> allOil = new HashMap<String, Object>();
//        BigDecimal orderLiterSum = BigDecimal.ZERO;
//        BigDecimal receivableAmtSum = BigDecimal.ZERO;
//        BigDecimal amtSum = BigDecimal.ZERO;
//        BigDecimal discountAmtSum = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSum = BigDecimal.ZERO;
//        BigDecimal orderCountSum = BigDecimal.ZERO;
//        for (Map<String, Object> itemOil : queryGroupByOil) {
//            Object orderLiterObj = itemOil.get("order_liters");
//            double orderLiterDouble = (orderLiterObj != null) ? (double) orderLiterObj : 0.0;
//            BigDecimal orderLiter = BigDecimal.valueOf(orderLiterDouble);
//            if (orderLiter != null) {
//                orderLiterSum = orderLiterSum.add(orderLiter);
//            }
//
//            Object receivableAmtObj = itemOil.get("receivable_amt");
//            double receivableAmtDouble = (receivableAmtObj != null) ? (double) receivableAmtObj : 0.0;
//            BigDecimal receivableAmt = BigDecimal.valueOf(receivableAmtDouble);
//            if (receivableAmt != null) {
//                receivableAmtSum = receivableAmtSum.add(receivableAmt);
//            }
//
//            Object amtObj = itemOil.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSum = amtSum.add(amt);
//            }
//
//            Object discountAmtObj = itemOil.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSum = discountAmtSum.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemOil.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSum = discountCouponAmtSum.add(discountCouponAmt);
//            }
//
//            Object orderCountObj = itemOil.get("order_count");
//            BigDecimal orderCount = (orderCountObj != null) ? (BigDecimal) orderCountObj : BigDecimal.ZERO;
//            BigDecimal orderCountBigDecimal = orderCount;
//            if (orderCountBigDecimal != null) {
//                orderCountSum = orderCountSum.add(orderCountBigDecimal);
//            }
//        }
//        allOil.put("oil_name", "合计");
//        allOil.put("order_liters", orderLiterSum);
//        allOil.put("receivable_amt", receivableAmtSum);
//        allOil.put("amt", amtSum);
//        allOil.put("discount_amt", discountAmtSum);
//        allOil.put("discount_coupon_amt", discountCouponAmtSum);
//        allOil.put("order_count", orderCountSum);
//        queryGroupByOil.add(allOil);
//        return queryGroupByOil;
//    }
//
//    @Override
//    public List<Map<String, Object>> queryReportByOil(Map<String, Object> params) {
//        List<Map<String, Object>> queryGroupByOil = classSettlementMapper.queryReportByOil(params);
//
//        Iterator<Map<String, Object>> iterator = queryGroupByOil.iterator();
//        while (iterator.hasNext()) {
//            Map<String, Object> map = iterator.next();
//            if (!map.containsKey("oil_name")) {
//                iterator.remove();
//            }
//        }
//        Map<String, Object> allOil = new HashMap<String, Object>();
//        BigDecimal orderLiterSum = BigDecimal.ZERO;
//        BigDecimal receivableAmtSum = BigDecimal.ZERO;
//        BigDecimal amtSum = BigDecimal.ZERO;
//        BigDecimal discountAmtSum = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSum = BigDecimal.ZERO;
//        BigDecimal orderCountSum = BigDecimal.ZERO;
//        BigDecimal actual_recharge_received_amt = BigDecimal.ZERO;
//
//        for (Map<String, Object> itemOil : queryGroupByOil) {
//            Object orderLiterObj = itemOil.get("order_liters");
//            double orderLiterDouble = (orderLiterObj != null) ? (double) orderLiterObj : 0.0;
//            BigDecimal orderLiter = BigDecimal.valueOf(orderLiterDouble);
//            if (orderLiter != null) {
//                orderLiterSum = orderLiterSum.add(orderLiter);
//            }
//
//            Object receivableAmtObj = itemOil.get("receivable_amt");
//            double receivableAmtDouble = (receivableAmtObj != null) ? (double) receivableAmtObj : 0.0;
//            BigDecimal receivableAmt = BigDecimal.valueOf(receivableAmtDouble);
//            if (receivableAmt != null) {
//                receivableAmtSum = receivableAmtSum.add(receivableAmt);
//            }
//
//            Object amtObj = itemOil.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSum = amtSum.add(amt);
//            }
//
//            Object discountAmtObj = itemOil.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSum = discountAmtSum.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemOil.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSum = discountCouponAmtSum.add(discountCouponAmt);
//            }
//
//            Object orderCountObj = itemOil.get("order_count");
//            BigDecimal orderCount = (orderCountObj != null) ? (BigDecimal) orderCountObj : BigDecimal.ZERO;
//            BigDecimal orderCountBigDecimal = orderCount;
//            if (orderCountBigDecimal != null) {
//                orderCountSum = orderCountSum.add(orderCountBigDecimal);
//            }
//
//            Object actual_recharge_received_amtObj = itemOil.get("actual_recharge_received_amt");
//            BigDecimal actual_recharge_received_amtCount = (actual_recharge_received_amtObj != null) ? (BigDecimal) actual_recharge_received_amtObj : BigDecimal.ZERO;
//            BigDecimal actual_recharge_received_amtBigDecimal = actual_recharge_received_amtCount;
//            if (actual_recharge_received_amtBigDecimal != null) {
//                actual_recharge_received_amt = actual_recharge_received_amt.add(actual_recharge_received_amtBigDecimal);
//            }
//        }
//        allOil.put("oil_name", "小计");
//        allOil.put("order_liters", orderLiterSum);
//        allOil.put("receivable_amt", receivableAmtSum);
//        allOil.put("amt", amtSum);
//        allOil.put("discount_amt", discountAmtSum);
//        allOil.put("discount_coupon_amt", discountCouponAmtSum);
//        allOil.put("order_count", orderCountSum);
//        queryGroupByOil.add(allOil);
//        Map<String, Object> changeOil = new HashMap<String, Object>();
//        allOil.put("oil_name", "充值");
//        allOil.put("order_liters", 0);
//        allOil.put("receivable_amt", actual_recharge_received_amt);
//        allOil.put("amt", actual_recharge_received_amt);
//        allOil.put("discount_amt", 0);
//        allOil.put("discount_coupon_amt", 0);
//        allOil.put("order_count", 0);
//        queryGroupByOil.add(changeOil);
//        Map<String, Object> allallOil = new HashMap<String, Object>();
//        allOil.put("oil_name", "合计");
//        allOil.put("order_liters", 0);
//        allOil.put("receivable_amt", receivableAmtSum.add(actual_recharge_received_amt));
//        allOil.put("amt", amtSum.add(actual_recharge_received_amt));
//        allOil.put("discount_amt", 0);
//        allOil.put("discount_coupon_amt", 0);
//        allOil.put("order_count", 0);
//        Iterator<Map<String, Object>> iteraoor = queryGroupByOil.iterator();
//        while (iteraoor.hasNext()) {
//            Map<String, Object> map = iteraoor.next();
//            if (!map.containsKey("oil_name")) {
//                iteraoor.remove();
//            }
//        }
//        return queryGroupByOil;
//    }
//
//    @Override
//    public List<Map<String, Object>> queryGroupByPayTypeForOrder(Map<String, Object> params) {
//        return classSettlementMapper.queryGroupByPayTypeForOrder(params);
//    }
//
//    @Override
//    public List<Map<String, Object>> getShiftHandover(Map<String, Object> params) {
//        List<Map<String, Object>> queryClassByNo = classSettlementMapper.queryReportClassByNo(params);
//        Map<String, Object> jiequeryMap = new HashMap<String, Object>();
//        Object startTime = queryClassByNo.get(0).get("class_start_time");
//        Object endTime = queryClassByNo.get(0).get("class_end_time");
//        Object stationId = queryClassByNo.get(0).get("station_id");
//        if(startTime == null){
//            startTime = "1099-11-23 11:06:50";
//        }
//        jiequeryMap.put("startTime",startTime);
//        jiequeryMap.put("stationId",stationId);
//        jiequeryMap.put("endTime",endTime);
//        List<Map<String, Object>> a= classSettlementMapper.getShiftHandover(jiequeryMap);
//
//
//return a;
//    }
//
//    @Override
//    public List<Map<String, Object>> getSuccession(Map<String, Object> params) {
//        return  classSettlementMapper.queryReportClassByNo(params);
//
//    }
//
//
//
//    @Override
//    public List<Map<String, Object>> employeeQueryGroupByPayTypeForOrder(Map<String, Object> params) {
//        return classSettlementMapper.employeeQueryGroupByPayTypeForOrder(params);
//    }
//
//
//
//    @Override
//    public List<Map<String, Object>> queryGroupByPayType(Map<String, Object> params) {
//        List<Map<String, Object>> queryGroupByPayType = classSettlementMapper.queryGroupByPayType(params);
//        Iterator<Map<String, Object>> iterator3 = queryGroupByPayType.iterator();
//        while (iterator3.hasNext()) {
//            Map<String, Object> map = iterator3.next();
//            if (!map.containsKey("pay_type")) {
//                iterator3.remove();
//            }
//        }
//        Map<String, Object> allPayType = new HashMap<>();
//        BigDecimal amtSum2 = BigDecimal.ZERO;
//        BigDecimal refundAmtSum2 = BigDecimal.ZERO;
//        BigDecimal discountAmtSum2 = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSum2 = BigDecimal.ZERO;
//
//        for (Map<String, Object> itemPayType : queryGroupByPayType) {
//            Object amtObj = itemPayType.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSum2 = amtSum2.add(amt);
//            }
//
//            Object refundAmtObj = itemPayType.get("refund_amt");
//            double refundAmtDouble = (refundAmtObj != null) ? (double) refundAmtObj : 0.0;
//            BigDecimal refundAmt = BigDecimal.valueOf(refundAmtDouble);
//            if (refundAmt != null) {
//                refundAmtSum2 = refundAmtSum2.add(refundAmt);
//            }
//
//            Object discountAmtObj = itemPayType.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSum2 = discountAmtSum2.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemPayType.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSum2 = discountCouponAmtSum2.add(discountCouponAmt);
//            }
//        }
//        for(Map<String, Object> item :queryGroupByPayType){
//            Map<String, Object> queryMap = new HashMap<String, Object>();
//            queryMap.put("payType", item.get("pay_type"));
//            queryMap.put("stationId", item.get("station_id"));
//         String orderPayType = classSettlementMapper.queryOrderPayType(queryMap);
//         if(orderPayType!=null){
//             item.put("pay_type",orderPayType);
//         }
//        }
//        allPayType.put("pay_type", "合计");
//        allPayType.put("amt", amtSum2);
//        allPayType.put("refund_amt", refundAmtSum2);
//        allPayType.put("discount_amt", discountAmtSum2);
//        allPayType.put("discount_coupon_amt", discountCouponAmtSum2);
//
//        queryGroupByPayType.add(allPayType);
//        return queryGroupByPayType;
//    }
//
//    @Override
//    public BigDecimal getAllTransaction(Map<String, Object> params,CardClassSettDto settDto) {
//        List<Map<String, Object>> queryClassByNo = classSettlementMapper.queryReportClassByNo(params);
//        ClassSettlementCard physicalCard = new  ClassSettlementCard();
//        ClassSettlementCard fleetCard = new  ClassSettlementCard();
//        if (!queryClassByNo.isEmpty()) {
//            Map<String, Object> queryMap = new HashMap<String, Object>();
//            Object startTime = queryClassByNo.get(0).get("class_start_time");
//            Object endTime = queryClassByNo.get(0).get("class_end_time");
//            Object stationId = queryClassByNo.get(0).get("station_id");
//
//            if (startTime != null) {
//                String oilstartTime = startTime.toString().substring(0, 19);
//                queryMap.put("createStartTime", oilstartTime);
//            }
//
//            if (endTime != null) {
//                String oilendTime = endTime.toString().substring(0, 19);
//                queryMap.put("createEndTime", oilendTime);
//            }
//
//            if (stationId != null) {
//                queryMap.put("stationId", stationId);
//            }
//
//            if (endTime != null && stationId != null) {
//                physicalCard = classSettlementMapper.queryPhysicalCard(queryMap);
//
//                fleetCard = classSettlementMapper.queryFleetCard(queryMap);
//
//
//            }}
//        BigDecimal posTransactionAmt = (settDto.getTotalAmt() != null) ?  settDto.getTotalAmt() : BigDecimal.ZERO;
//        BigDecimal dkqTransactionAmt = (physicalCard.getAmt() != null) ?  physicalCard.getAmt() : BigDecimal.ZERO;
//        BigDecimal cdkTransactionAmt = (fleetCard.getAmt() != null) ?  fleetCard.getAmt()  : BigDecimal.ZERO;
//        return posTransactionAmt.add(dkqTransactionAmt).add(cdkTransactionAmt);
//    }
//
//    @Override
//    public int getAllNewPeople(Map<String, Object> params) {
//        List<Map<String, Object>> queryClassByNo = classSettlementMapper.queryReportClassByNo(params);
//int allNewPeople= 0;
//        if (!queryClassByNo.isEmpty()) {
//            Map<String, Object> queryMap = new HashMap<String, Object>();
//            Object startTime = queryClassByNo.get(0).get("class_start_time");
//            Object endTime = queryClassByNo.get(0).get("class_end_time");
//            Object stationId = queryClassByNo.get(0).get("station_id");
//
//            if (startTime != null) {
//                String oilstartTime = startTime.toString().substring(0, 19);
//                queryMap.put("createStartTime", oilstartTime);
//            }
//
//            if (endTime != null) {
//                String oilendTime = endTime.toString().substring(0, 19);
//                queryMap.put("createEndTime", oilendTime);
//            }
//
//            if (stationId != null) {
//                queryMap.put("stationId", stationId);
//            }
//
//            if (endTime != null && stationId != null) {
//
//                allNewPeople=   classSettlementMapper.getAllNewPeople(queryMap);
//            }}
//
//        return allNewPeople;
//    }
//
//
//    @Override
//    public List<Map<String, Object>> queryReportByPayType(Map<String, Object> params,CardClassSettDto settDto) {
//        List<Map<String, Object>> queryGroupByPayType = classSettlementMapper.queryReportByPayType(params);
//        List<Map<String, Object>> queryClassByNo = classSettlementMapper.queryReportClassByNo(params);
//        ClassSettlementCard physicalCard = new  ClassSettlementCard();
//        ClassSettlementCard fleetCard = new  ClassSettlementCard();
//        ClassSettlementCard superPay = new  ClassSettlementCard();
//
//        ClassSettlementCard forSaleActivity = new  ClassSettlementCard();
//        int xjint = 0;
//        int wxint = 0;
//        if (!queryClassByNo.isEmpty()) {
//            Map<String, Object> queryMap = new HashMap<String, Object>();
//            Object startTime = queryClassByNo.get(0).get("class_start_time");
//            Object endTime = queryClassByNo.get(0).get("class_end_time");
//            Object stationId = queryClassByNo.get(0).get("station_id");
//
//            if (startTime != null) {
//                String oilstartTime = startTime.toString().substring(0, 19);
//                queryMap.put("createStartTime", oilstartTime);
//            }
//
//            if (endTime != null) {
//                String oilendTime = endTime.toString().substring(0, 19);
//                queryMap.put("createEndTime", oilendTime);
//            }
//
//            if (stationId != null) {
//                queryMap.put("stationId", stationId);
//            }
//
//            if (endTime != null && stationId != null) {
//                 physicalCard = classSettlementMapper.queryPhysicalCard(queryMap);
//
//                 fleetCard = classSettlementMapper.queryFleetCard(queryMap);
//
//                 superPay = this.querySuperPay(queryMap);
//
//
//
//                 forSaleActivity  =    classSettlementMapper.saleActivityAmtClass(params);
//            }}
//
//
//                Iterator<Map<String, Object>> iterator3 = queryGroupByPayType.iterator();
//        while (iterator3.hasNext()) {
//            Map<String, Object> map = iterator3.next();
//            if (!map.containsKey("pay_type")) {
//                iterator3.remove();
//            }
//            Object pay_typeObj = map.get("pay_type");
//            String pay_typeStr = (pay_typeObj != null) ? (String) pay_typeObj : "其他";
//            if(pay_typeStr.equals("xj")){
//                xjint++;
//            }
//            if(pay_typeStr.equals("wx")){
//                wxint++;
//            }
//        }
//        Map<String, Object> allPayType = new HashMap<>();
//        BigDecimal amtSum2 = BigDecimal.ZERO;
//        BigDecimal refundAmtSum2 = BigDecimal.ZERO;
//        BigDecimal discountAmtSum2 = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSum2 = BigDecimal.ZERO;
//        BigDecimal  orderLiters2 = BigDecimal.ZERO;
//        BigDecimal transaction_amtSum = BigDecimal.ZERO;
//        BigDecimal totalAmtSum2 = BigDecimal.ZERO;
//        BigDecimal  commission2 = BigDecimal.ZERO;
//        BigDecimal  withdrawalAmount2 = BigDecimal.ZERO;
//        BigDecimal posTransactionAmt = (settDto.getTotalAmt() != null) ?  settDto.getTotalAmt() : BigDecimal.ZERO;
//        BigDecimal dkqTransactionAmt = (physicalCard.getAmt() != null) ?  physicalCard.getAmt() : BigDecimal.ZERO;
//        BigDecimal cdkTransactionAmt = (fleetCard.getAmt() != null) ?  fleetCard.getAmt()  : BigDecimal.ZERO;
//
////        秒杀金额
//        BigDecimal forSaleActivityAmt =  forSaleActivity.getAmt()!=null?forSaleActivity.getAmt():BigDecimal.ZERO;
//        BigDecimal forSaleActivityCom =  forSaleActivity.getServiceCharge()!=null?forSaleActivity.getServiceCharge():BigDecimal.ZERO;
//        BigDecimal forSaleActivityTx =  forSaleActivity.getWithdrawalAmount()!=null?forSaleActivity.getWithdrawalAmount():BigDecimal.ZERO;
//        BigDecimal forSaleActivityRef =   forSaleActivity.getRefundAmount()!=null?forSaleActivity.getRefundAmount():BigDecimal.ZERO;
//
//
//        BigDecimal posimp = BigDecimal.ZERO;
//        BigDecimal posmsub = BigDecimal.ZERO;
//        BigDecimal poswx = BigDecimal.ZERO;
//        BigDecimal poswxCommission = BigDecimal.ZERO;
//        BigDecimal posrefCommission = BigDecimal.ZERO;
//        BigDecimal poswxWithdrawalAmount = BigDecimal.ZERO;
//        BigDecimal posref = BigDecimal.ZERO;
//
//
//
//        List<ClassSettlementCard>  classSettlementCardL = settDto.getSettlementCardList();
////        MANUAL_ADD("imp","手动增加"),
////     *     MANUAL_SUB("msub","手动扣减"),
////     *     WX_RECHARGE("wx","微信充值"),
////     *     CONSUME("","电子卡支付"),
////     *     REFUND("ref","充值退款"),*/
//       for (ClassSettlementCard classSettlementCardS:classSettlementCardL){
//           if ( classSettlementCardS.getPayType().equals("imp")){
//               posimp = classSettlementCardS.getAmt();
//           }
//           if ( classSettlementCardS.getPayType().equals("msub")){
//               posmsub = classSettlementCardS.getAmt();
//           }
//           if ( classSettlementCardS.getPayType().equals("wx")){
//               poswx = classSettlementCardS.getAmt();
//               poswxCommission = classSettlementCardS.getServiceCharge();
//               poswxWithdrawalAmount = classSettlementCardS.getWithdrawalAmount();
//           }
//           if ( classSettlementCardS.getPayType().equals("ref")){
//               posref = classSettlementCardS.getAmt();
//               posrefCommission = classSettlementCardS.getServiceCharge();
//           }
//
//       }
//        if (xjint ==0){
//            Map<String, Object> xjPayType = new HashMap<>();
//            xjPayType.put("pay_type", "xj");
//            xjPayType.put("amt", 0.0);
//                    xjPayType.put("order_liters", 0.0);
//                    xjPayType.put("refund_amt", 0.0);
//            xjPayType.put("discount_amt", 0.0);
//            xjPayType.put("discount_coupon_amt", 0.0);
//            xjPayType.put("transaction_amt",BigDecimal.ZERO);
//            queryGroupByPayType.add(xjPayType);
//        }
//        if (wxint ==0){
//            Map<String, Object> wxPayType = new HashMap<>();
//            wxPayType.put("pay_type", "wx");
//            wxPayType.put("amt", 0.0);
//            wxPayType.put("order_liters", 0.0);
//            wxPayType.put("refund_amt", 0.0);
//            wxPayType.put("discount_amt", 0.0);
//            wxPayType.put("discount_coupon_amt", 0.0);
//            wxPayType.put("transaction_amt",BigDecimal.ZERO);
//            queryGroupByPayType.add(wxPayType);
//        }
////最终做一次处理
//        for (Map<String, Object> itemPayType : queryGroupByPayType) {
//
//            Object pay_typeObj = itemPayType.get("pay_type");
//            String pay_typeStr = (pay_typeObj != null) ? (String) pay_typeObj : "其他";
//                Map<String, Object> OrderPayqueryMap = new HashMap<String, Object>();
//                OrderPayqueryMap.put("payType", pay_typeStr);
//                OrderPayqueryMap.put("stationId", params.get("stationId"));
//                String orderPayType = classSettlementMapper.queryOrderPayType(OrderPayqueryMap);
//                if(orderPayType!=null){
//                    itemPayType.put("pay_type",orderPayType);
//                }
//            Object amtObj = itemPayType.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//
//            Object withdrawal_amountObj = itemPayType.get("withdrawal_amount");
//            BigDecimal withdrawalAmount = (withdrawal_amountObj != null) ? (BigDecimal) withdrawal_amountObj : BigDecimal.ZERO;
//
//
//            Object commissionObj = itemPayType.get("commission");
//            BigDecimal commissionAmount = (commissionObj != null) ? (BigDecimal) commissionObj : BigDecimal.ZERO;
//
//
//            if (amt != null) {
//                amtSum2 = amtSum2.add(amt);
//
//            }
//            itemPayType.put("total",amt);
//            if (pay_typeStr.equals("xj")) {
//                itemPayType.put("transaction_amt",dkqTransactionAmt.add(cdkTransactionAmt).add(posimp));
//                itemPayType.put("total",amt.add(dkqTransactionAmt.add(cdkTransactionAmt).add(posimp)));
//                itemPayType.put("commission",BigDecimal.ZERO);
//                itemPayType.put("withdrawal_amount",BigDecimal.ZERO);
//                itemPayType.put("sale_activity_amt",BigDecimal.ZERO);
//            }else if(pay_typeStr.equals("wx")){
//                itemPayType.put("transaction_amt",poswx);
//                itemPayType.put("total",amt.add(poswx).add(forSaleActivityAmt));
//                itemPayType.put("commission",commissionAmount.add(poswxCommission).subtract(posrefCommission).add(superPay.getServiceCharge()!=null?superPay.getServiceCharge():BigDecimal.ZERO).add(forSaleActivityCom));
//                itemPayType.put("withdrawal_amount",withdrawalAmount.add(poswxWithdrawalAmount).add(superPay.getWithdrawalAmount()!=null?superPay.getWithdrawalAmount():BigDecimal.ZERO).add(forSaleActivityTx));
//                itemPayType.put("sale_activity_amt",forSaleActivityAmt);
//            }else{
//                itemPayType.put("transaction_amt",BigDecimal.ZERO);
//                itemPayType.put("sale_activity_amt",BigDecimal.ZERO);
//            }
//            Object commissionObj2 = itemPayType.get("commission");
//            BigDecimal commissionAmount2 = (commissionObj2 != null) ? (BigDecimal) commissionObj2 : BigDecimal.ZERO;
//            Object withdrawal_amountObj2 = itemPayType.get("withdrawal_amount");
//            BigDecimal withdrawalAmt2 = (withdrawal_amountObj2 != null) ? (BigDecimal) withdrawal_amountObj2 : BigDecimal.ZERO;
//            Object refundAmtObj = itemPayType.get("refund_amt");
//            double refundAmtDouble = (refundAmtObj != null) ? (double) refundAmtObj : 0.0;
//            BigDecimal refundAmt = BigDecimal.valueOf(refundAmtDouble);
//            if (refundAmt != null) {
//                Object paytypeObj = itemPayType.get("pay_type");
//                String paytypeStr = (paytypeObj != null) ? (String) paytypeObj : "其他";
//              if(paytypeStr.equals("xj")){
//                  refundAmt= refundAmt.add(posmsub);
//                  itemPayType.put("refund_amt",refundAmt);
//
//              }
//                if(paytypeStr.equals("wx")){
//                    refundAmt= refundAmt.add(posref);
//                    itemPayType.put("refund_amt",refundAmt.add(superPay.getRefundAmount()).add(forSaleActivityRef));
//                    refundAmtSum2 = refundAmtSum2.add(superPay.getRefundAmount().add(forSaleActivityRef));
//                }
//                refundAmtSum2 = refundAmtSum2.add(refundAmt);
//            }
//
//            Object discountAmtObj = itemPayType.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSum2 = discountAmtSum2.add(discountAmt);
//            }
//
//              commission2 = commission2.add(commissionAmount2);
//              withdrawalAmount2 = withdrawalAmount2.add(withdrawalAmt2);
//
//            Object discountCouponAmtObj = itemPayType.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSum2 = discountCouponAmtSum2.add(discountCouponAmt);
//            }
//            Object orderLitersObj = itemPayType.get("order_liters");
//            double orderLitersDouble = (orderLitersObj != null) ? (double) orderLitersObj : 0.0;
//            BigDecimal orderLiters = BigDecimal.valueOf(orderLitersDouble);
//            if (orderLiters != null) {
//                orderLiters2 = orderLiters2.add(orderLiters);
//            }
//
//            Object transaction_amtObj = itemPayType.get("transaction_amt");
//            BigDecimal transaction_amt = (transaction_amtObj != null) ? (BigDecimal) transaction_amtObj : BigDecimal.ZERO;
//
//            if (transaction_amt != null) {
//                transaction_amtSum = transaction_amtSum.add(transaction_amt);
//            }
//            Object totalAmtObj = itemPayType.get("total");
//            BigDecimal totalAmt = (totalAmtObj != null) ? (BigDecimal) totalAmtObj :BigDecimal.ZERO;
//
//            if (totalAmt != null) {
//                totalAmtSum2 = totalAmtSum2.add(totalAmt);
//            }
//        }
//
//
//        allPayType.put("pay_type", "合计");
//        allPayType.put("amt", amtSum2);
//        allPayType.put("refund_amt", refundAmtSum2);
//        allPayType.put("discount_amt", discountAmtSum2);
//        allPayType.put("discount_coupon_amt", discountCouponAmtSum2);
//        allPayType.put("order_liters", orderLiters2);
//        allPayType.put("transaction_amt",transaction_amtSum);
//        allPayType.put("total",totalAmtSum2);
//        allPayType.put("commission",commission2);
//        allPayType.put("withdrawal_amount",withdrawalAmount2);
//        allPayType.put("sale_activity_amt",forSaleActivityAmt);
//        queryGroupByPayType.add(allPayType);
//        return queryGroupByPayType;
//    }
//
//    @Override
//    public List<Map<String, Object>> queryGroupByOilGun(Map<String, Object> params) {
//        List<Map<String, Object>> queryGroupByOilGun = classSettlementMapper.queryGroupByOilGun(params);
//        Iterator<Map<String, Object>> iterator2 = queryGroupByOilGun.iterator();
//        while (iterator2.hasNext()) {
//            Map<String, Object> map = iterator2.next();
//            if (!map.containsKey("oil_gun")) {
//                iterator2.remove();
//            }
//        }
//        List<Map<String, Object>> queryClassByNo = classSettlementMapper.queryClassByNo(params);
//        if (!queryClassByNo.isEmpty()) {
//            Map<String, Object> queryMap = new HashMap<String, Object>();
//            Object startTime = queryClassByNo.get(0).get("class_start_time");
//            Object endTime = queryClassByNo.get(0).get("class_end_time");
//            Object stationId = queryClassByNo.get(0).get("station_id");
//
//            if (startTime != null) {
//                String oilstartTime = startTime.toString().substring(0, 19);
//                queryMap.put("createStartTime", oilstartTime);
//            }
//
//            if (endTime != null) {
//                String oilendTime = endTime.toString().substring(0, 19);
//                queryMap.put("createEndTime", oilendTime);
//            }
//
//            if (stationId != null) {
//                queryMap.put("stationId", stationId);
//            }
//
//            if (endTime != null && stationId != null) {
//                List<OilEngineDto> newQueryGroupByOilGun = classSettlementMapper.classSettlementOilEngineSum(queryMap);
//                List<String> oilGunListA = new ArrayList<>();
//                List<String> oilGunListB = new ArrayList<>();
//                if (queryGroupByOilGun.size() > 0 && newQueryGroupByOilGun.size() > 0) {
//                    for (Map<String, Object> map : queryGroupByOilGun) {
//                        String oilGun = map.get("oil_gun").toString();
//                        oilGunListA.add(oilGun); // 存储a列表的油枪数据
//                        oilGunListB.clear();
//                        for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                            oilGunListB.add(oilEngineDto.getOilGun());
//                            if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//                                map.put("oil_price", oilEngineDto.getOilPrice());
//                                map.put("order_liters", oilEngineDto.getOrderLiters());
//                                map.put("oil_name", oilEngineDto.getOilName());
//                                map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                                map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                            }
//                        }
//                    }
//                    List<String> difference = new ArrayList<>();
//                    for (String value : oilGunListB) {
//                        if (!oilGunListA.contains(value)) {
//                            difference.add(value);
//                        }
//                    }
//                    for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                        for (String oilGun : difference) {
//
//                            if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//
//                                Map<String, Object> map = new HashMap<>();
//                                map.put("oil_gun", oilEngineDto.getOilGun());
//                                map.put("oil_price", oilEngineDto.getOilPrice());
//                                map.put("order_liters", oilEngineDto.getOrderLiters());
//                                map.put("oil_name", oilEngineDto.getOilName());
//                                map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                                map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                                queryGroupByOilGun.add(map);
//                            }
//                        }
//                    }
//
//                } else if (queryGroupByOilGun.size() == 0 && newQueryGroupByOilGun.size() > 0) {
//                    for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                        if (oilEngineDto != null && oilEngineDto.getOilGun() != null) {
//                            Map<String, Object> map = new HashMap<>();
//                            map.put("oil_gun", oilEngineDto.getOilGun());
//                            map.put("oil_price", oilEngineDto.getOilPrice());
//                            map.put("order_liters", oilEngineDto.getOrderLiters());
//                            map.put("oil_name", oilEngineDto.getOilName());
//                            map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                            map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                            queryGroupByOilGun.add(map);
//
//                        }
//                    }
//                }
//            }
//        }
//        return queryGroupByOilGun;
//    }
//
//    @Override
//    public List<Map<String, Object>> queryReportByOilGun(Map<String, Object> params) {
//        List<Map<String, Object>> queryGroupByOilGun = classSettlementMapper.queryReportByOilGun(params);
//        Iterator<Map<String, Object>> iterator2 = queryGroupByOilGun.iterator();
//        while (iterator2.hasNext()) {
//            Map<String, Object> map = iterator2.next();
//            if (!map.containsKey("oil_gun")) {
//                iterator2.remove();
//            }
//        }
//        List<Map<String, Object>> queryClassByNo = classSettlementMapper.queryReportClassByNo(params);
//        if (!queryClassByNo.isEmpty()) {
//            Map<String, Object> queryMap = new HashMap<String, Object>();
//            Object startTime = queryClassByNo.get(0).get("class_start_time");
//            Object endTime = queryClassByNo.get(0).get("class_end_time");
//            Object stationId = queryClassByNo.get(0).get("station_id");
//
//            if (startTime != null) {
//                String oilstartTime = startTime.toString().substring(0, 19);
//                queryMap.put("createStartTime", oilstartTime);
//            }
//
//            if (endTime != null) {
//                String oilendTime = endTime.toString().substring(0, 19);
//                queryMap.put("createEndTime", oilendTime);
//            }
//
//            if (stationId != null) {
//                queryMap.put("stationId", stationId);
//            }
//
//            if (endTime != null && stationId != null) {
//                List<OilEngineDto> newQueryGroupByOilGun = classSettlementMapper.classSettlementOilEngineSum(queryMap);
//                List<String> oilGunListA = new ArrayList<>();
//                List<String> oilGunListB = new ArrayList<>();
//                if (queryGroupByOilGun.size() > 0 && newQueryGroupByOilGun.size() > 0) {
//                    for (Map<String, Object> map : queryGroupByOilGun) {
//                        String oilGun = map.get("oil_gun").toString();
//                        oilGunListA.add(oilGun); // 存储a列表的油枪数据
//                        oilGunListB.clear();
//                        for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                            oilGunListB.add(oilEngineDto.getOilGun());
//                            if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//                                map.put("oil_price", oilEngineDto.getOilPrice());
//                                map.put("order_liters", oilEngineDto.getOrderLiters());
//                                map.put("oil_name", oilEngineDto.getOilName());
//                                map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                                map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                                double dStartFlowMeterDouble = ( oilEngineDto.getStartFlowMeter() != null) ? (double)  oilEngineDto.getStartFlowMeter() : 0.0;
//                                double dEndFlowMeteDouble = (oilEngineDto.getEndFlowMeter() != null) ? (double) oilEngineDto.getEndFlowMeter() : 0.0;
//                                BigDecimal dStartFlowMeterAmt = BigDecimal.valueOf(dStartFlowMeterDouble);
//                                BigDecimal dEndFlowMeteAmt = BigDecimal.valueOf(dEndFlowMeteDouble);
//                                map.put("totalWord", dEndFlowMeteAmt.subtract(dStartFlowMeterAmt));
//                            }
//                        }
//                    }
//                    List<String> difference = new ArrayList<>();
//                    for (String value : oilGunListB) {
//                        if (!oilGunListA.contains(value)) {
//                            difference.add(value);
//                        }
//                    }
//                    for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                        for (String oilGun : difference) {
//
//                            if (oilEngineDto != null && oilEngineDto.getOilGun() != null && oilEngineDto.getOilGun().equals(oilGun)) {
//
//                                Map<String, Object> map = new HashMap<>();
//                                map.put("oil_gun", oilEngineDto.getOilGun());
//                                map.put("oil_price", oilEngineDto.getOilPrice());
//                                map.put("order_liters", oilEngineDto.getOrderLiters());
//                                map.put("oil_name", oilEngineDto.getOilName());
//                                map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                                map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                                double dStartFlowMeterDouble = ( oilEngineDto.getStartFlowMeter() != null) ? (double)  oilEngineDto.getStartFlowMeter() : 0.0;
//                                double dEndFlowMeteDouble = (oilEngineDto.getEndFlowMeter() != null) ? (double) oilEngineDto.getEndFlowMeter() : 0.0;
//                                BigDecimal dStartFlowMeterAmt = BigDecimal.valueOf(dStartFlowMeterDouble);
//                                BigDecimal dEndFlowMeteAmt = BigDecimal.valueOf(dEndFlowMeteDouble);
//                                map.put("totalWord", dEndFlowMeteAmt.subtract(dStartFlowMeterAmt));
//                                queryGroupByOilGun.add(map);
//                            }
//                        }
//                    }
//
//                } else if (queryGroupByOilGun.size() == 0 && newQueryGroupByOilGun.size() > 0) {
//                    for (OilEngineDto oilEngineDto : newQueryGroupByOilGun) {
//                        if (oilEngineDto != null && oilEngineDto.getOilGun() != null) {
//                            Map<String, Object> map = new HashMap<>();
//                            map.put("oil_gun", oilEngineDto.getOilGun());
//                            map.put("oil_price", oilEngineDto.getOilPrice());
//                            map.put("order_liters", oilEngineDto.getOrderLiters());
//                            map.put("oil_name", oilEngineDto.getOilName());
//                            map.put("startFlowMeter", oilEngineDto.getStartFlowMeter());
//                            map.put("endFlowMeter", oilEngineDto.getEndFlowMeter());
//                            double dStartFlowMeterDouble = ( oilEngineDto.getStartFlowMeter() != null) ? (double)  oilEngineDto.getStartFlowMeter() : 0.0;
//                            double dEndFlowMeteDouble = (oilEngineDto.getEndFlowMeter() != null) ? (double) oilEngineDto.getEndFlowMeter() : 0.0;
//                            BigDecimal dStartFlowMeterAmt = BigDecimal.valueOf(dStartFlowMeterDouble);
//                            BigDecimal dEndFlowMeteAmt = BigDecimal.valueOf(dEndFlowMeteDouble);
//                            map.put("totalWord", dEndFlowMeteAmt.subtract(dStartFlowMeterAmt));
//                            queryGroupByOilGun.add(map);
//
//                        }
//                    }
//                }
//            }
//        }
//        return queryGroupByOilGun;
//    }
//
//    @Override
//    public List<Map<String, Object>> queryGroupByOilGunForOrder(Map<String, Object> params) {
//        return classSettlementMapper.queryGroupByOilGunForOrder(params);
//    }
//
//    @Override
//    public List<Map<String, Object>> employeeQueryGroupByOilGunForOrder(Map<String, Object> params) {
//        return classSettlementMapper.employeeQueryGroupByOilGunForOrder(params);
//    }
//
//    @Override
//    public List<Map<String, Object>> queryGroupByActivity(Map<String, Object> params) {
//        return classSettlementMapper.queryGroupByActivity(params);
//    }
//
//    @Override
//    public List<Map<String, Object>> queryGroupByActivityForOrder(Map<String, Object> params) {
//        return classSettlementMapper.queryGroupByActivityForOrder(params);
//    }
//
//    @Override
//    public List<Map<String, Object>> selectClassSettlement4User4POSList(Map<String, Object> params) {
//        List<Map<String, Object>> listDetail4User = classSettlementMapper.selectClassSettlement4User4POSList(params);
//        Iterator<Map<String, Object>> iterator4 = listDetail4User.iterator();
//        while (iterator4.hasNext()) {
//            Map<String, Object> map = iterator4.next();
//            if (!map.containsKey("oil_name")) {
//                iterator4.remove();
//            }
//        }
//        Map<String, Object> allDetail4User = new HashMap<String, Object>();
//        BigDecimal orderLiterSumForUser = BigDecimal.ZERO;
//        BigDecimal receivableAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal amtSumForUser = BigDecimal.ZERO;
//        BigDecimal discountAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal discountCouponAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal refundAmtSumForUser = BigDecimal.ZERO;
//        BigDecimal orderCountSumForUser = BigDecimal.ZERO;
//        BigDecimal moreAmtSumForUser = BigDecimal.ZERO;
//
//        for (Map<String, Object> itemOil : listDetail4User) {
//            Object orderLiterObj = itemOil.get("order_liters");
//            double orderLiterDouble = (orderLiterObj != null) ? (double) orderLiterObj : 0.0;
//            BigDecimal orderLiter = BigDecimal.valueOf(orderLiterDouble);
//            if (orderLiter != null) {
//                orderLiterSumForUser = orderLiterSumForUser.add(orderLiter);
//            }
//
//            Object receivableAmtObj = itemOil.get("receivable_amt");
//            double receivableAmtDouble = (receivableAmtObj != null) ? (double) receivableAmtObj : 0.0;
//            BigDecimal receivableAmt = BigDecimal.valueOf(receivableAmtDouble);
//            if (receivableAmt != null) {
//                receivableAmtSumForUser = receivableAmtSumForUser.add(receivableAmt);
//            }
//
//            Object amtObj = itemOil.get("amt");
//            double amtDouble = (amtObj != null) ? (double) amtObj : 0.0;
//            BigDecimal amt = BigDecimal.valueOf(amtDouble);
//            if (amt != null) {
//                amtSumForUser = amtSumForUser.add(amt);
//            }
//
//            Object discountAmtObj = itemOil.get("discount_amt");
//            double discountAmtDouble = (discountAmtObj != null) ? (double) discountAmtObj : 0.0;
//            BigDecimal discountAmt = BigDecimal.valueOf(discountAmtDouble);
//            if (discountAmt != null) {
//                discountAmtSumForUser = discountAmtSumForUser.add(discountAmt);
//            }
//
//            Object discountCouponAmtObj = itemOil.get("discount_coupon_amt");
//            double discountCouponAmtDouble = (discountCouponAmtObj != null) ? (double) discountCouponAmtObj : 0.0;
//            BigDecimal discountCouponAmt = BigDecimal.valueOf(discountCouponAmtDouble);
//            if (discountCouponAmt != null) {
//                discountCouponAmtSumForUser = discountCouponAmtSumForUser.add(discountCouponAmt);
//            }
//
//            Object refundAmtObj = itemOil.get("refund_amt");
//            double refundAmtDouble = (refundAmtObj != null) ? (double) refundAmtObj : 0.0;
//            BigDecimal refundAmt = BigDecimal.valueOf(refundAmtDouble);
//            if (refundAmt != null) {
//                refundAmtSumForUser = refundAmtSumForUser.add(refundAmt);
//            }
//
//            Object orderCountObj = itemOil.get("order_count");
//            BigDecimal orderCount = (orderCountObj != null) ? (BigDecimal) orderCountObj : BigDecimal.ZERO;
//            BigDecimal orderCountBigDecimal = orderCount;
//            if (orderCountBigDecimal != null) {
//                orderCountSumForUser = orderCountSumForUser.add(orderCountBigDecimal);
//            }
//
//            Object moreAmtObj = itemOil.get("more_amt");
//            double moreAmtDouble = (moreAmtObj != null) ? (double) moreAmtObj : 0.0;
//            BigDecimal moreAmt = BigDecimal.valueOf(moreAmtDouble);
//            if (moreAmt != null) {
//                moreAmtSumForUser = moreAmtSumForUser.add(moreAmt);
//            }
//        }
//
//        allDetail4User.put("oil_personnel_name", "合计");
//        allDetail4User.put("order_liters", orderLiterSumForUser);
//        allDetail4User.put("receivable_amt", receivableAmtSumForUser);
//        allDetail4User.put("amt", amtSumForUser);
//        allDetail4User.put("discount_amt", discountAmtSumForUser);
//        allDetail4User.put("discount_coupon_amt", discountCouponAmtSumForUser);
//        allDetail4User.put("refund_amt", refundAmtSumForUser);
//        allDetail4User.put("order_count", orderCountSumForUser);
//        allDetail4User.put("more_amt", moreAmtSumForUser);
//
//        listDetail4User.add(allDetail4User);
//        return listDetail4User;
//    }
//
//    @Override
//    public List<Map<String, Object>> selectClassSettlement4User4POSListForOrder(Map<String, Object> params) {
//        return classSettlementMapper.selectClassSettlement4User4POSListForOrder(params);
//    }
//
//    public List<Map<String, Object>> employeeSelectClassSettlement4User4POSListForOrder(Map<String, Object> params) {
//        return classSettlementMapper.employeeSelectClassSettlement4User4POSListForOrder(params);
//    }
//
//    @Override
//    //统计班结信息，按照支付方式进行集合
//    public List<ClassSettlement> queryClassSettlementPayType(Map<String, Object> params) {
//        List<ClassSettlement> queryGroupByPayType = classSettlementMapper.queryClassSettlementPayType(params);
//        for(ClassSettlement item :queryGroupByPayType){
//            Map<String, Object> queryMap = new HashMap<String, Object>();
//            queryMap.put("payType", item.getPayType());
//            queryMap.put("stationId", item.getStationId());
//            String orderPayType = classSettlementMapper.queryOrderPayType(queryMap);
//            if(orderPayType!=null){
//                item.setPayType(orderPayType);
//            }
//        }
//        return queryGroupByPayType;
//    }
//
//    @Override
//    //统计班结信息，按照油品名称进行集合
//    public List<ClassSettlement> queryClassSettlementOil(Map<String, Object> params) {
//        return classSettlementMapper.queryClassSettlementOil(params);
//    }
//
//    public String queryClassDayOrNight(Long stationId, Date createEndTime) {
//        Map<String, Object> params = new HashMap<>();
//        params.put("stationId", stationId);
//        SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
//        String formattedStartTime = format.format(createEndTime);
//        params.put("createEndTime", formattedStartTime);
//        return classSettlementMapper.queryClassDayOrNight(params);
//    }
//
//    public int getDayOrNightCount(Map<String, Object> params) {
//
//        return classSettlementMapper.getDayOrNightCount(params);
//    }
//
//
//
//
//    //统计班结信息，按照加油员分类
//    public List<ClassSettlement> selectClassSettlementSummaryUser(Map<String, Object> params) {
//        return classSettlementMapper.selectClassSettlementSummaryUser(params);
//    }
//
//
//    public void updateClassSettlementPrintStatus(String classNo) {
//        classSettlementMapper.updateClassSettlementPrintStatus(classNo);
//    }
//
//}
